Central Limit Theorem - Shiny app

Yann Claudel
20/01/2017

Central Limit Theorem

Definition

  • Xi (i=1 to n) is a collection of iid random variables with mean mu and variance var and Sn the average

\[ S_{n}=\frac{X_{1} + X_{2}+ ... + X_{n}}{n} \]

For large n, in accordance with the Central Limit Theorem, the mean of iid random variables should follow a normal distribution with mean = mu and variance = var/n

Or for large n, \( \frac{\bar X_n - mu}{var / \sqrt{n}} \) has a distribution like that of a standard normal.

The application

Synopsis

The purpose of the shiny application is to illustrate the Central Limit Theorem.
The user can choose :

  • The number of iid random variables : nVar
  • The number of observations to build the density : nObs
  • The distribution : dist

See the application
https://yclaudel.shinyapps.io/firstshinyap

The application

Calculation

  • The server is going to calcultate n means.
  • Each mean is the mean of nVar variables of the distribution dist.
mns = NULL
for (i in 1 : nObs) mns = c(mns, mean(dist(nVar)))
...
hist(mns)

A first example

Exponential distribution with a rate of 0.5 ( and 40 observations)

plot of chunk unnamed-chunk-2