A Demonstration of the Central Limit Theorem with R-Shiny App

-A User Guide-

A Coursera Student

BACKGROUND



Informally speaking, the central limit theorem tells us that when we collect sample means from a particular population for a sufficient amount of times, the mean of its distribution approaches the true population mean.

This is what this app demonstrates for us!

Methods

Generation of A Random Population Mean

With the start of the app, a random population mean is generated using a R's random number generator with mean value of 500 and standard deviation of 500.

PopMean <- round( rnorm(1, mean=500, sd=500), 2)
PopMean
## [1] -189.12

Sampling

Sample points with a user-specified sample size 'sampleSize' are generated based on the randomly generated population mean with a fixed standard deviation value of 500.

sampleSize = 10; round(rnorm(sampleSize, mean=PopMean, sd=500), 2)
##  [1] -611.88   16.88   -7.19  -97.08  240.63  243.34 -658.05  102.71
##  [9] -275.73  172.99

Basic Guide on User Interface

Sliders

Two sliders for user-specified sample size parameter settings.

  • Sample Size - data points per one sample
  • Num. of Samples - number of samples to collect

hints: greater the parameter values, faster it approaches the population mean


Buttons

  • Add Samples: collects new samples from the population and triggers a dynamic change in the mean of the distribution of the means. This change is also reflected in the histogram where its mean is displayed with a red verticle line.
  • Show True Pop. Mean: displays the the true population mean of the randomly generated population.

A Sample Result

Here is a near-normal distribution formed as a result of a sufficient sampling. As shown here, the mean of the distribution of the sample means is near its true population mean