Takes samples of size n
from 4 different distributions and
plots histograms of the means along with a normal curve with matching
mean and standard deviation. Creating the plots for different values
of n
demonstrates the Central Limit Theorem.
clt.examp(n = 1, reps = 10000, nclass = 16, norm.param=list(mean=0,sd=1),
gamma.param=list(shape=1, rate=1/3), unif.param=list(min=0,max=1),
beta.param=list(shape1=0.35, shape2=0.25))
This function is run for its side effect of creating plots. It returns NULL invisibly.
size of the individual samples
number of samples to take from each distribution
number of bars in the histograms
List with parameters passed to rnorm
List with parameters passed to rgamma
List with parameters passed to runif
List with parameters passed to rbeta
Greg Snow 538280@gmail.com
The 4 distributions sampled from are a Normal with defaults mean 0 and standard deviation 1, a gamma with defaults shape 1 (exponential) and lambda 1/3 (mean = 3), a uniform distribution from 0 to 1 (default), and a beta distribution with default alpha 0.35 and beta 0.25 (U shaped left skewed).
The norm.param
, gamma.param
, unif.param
, and
beta.param
arguments can be used to change the parameters of
the generating distributions.
Running the function with n
=1 will show the populations. Run
the function again with n
at higher values to show that the
sampling distribution of the uniform quickly becomes normal and the
exponential and beta distributions eventually become normal (but much
slower than the uniform).
clt.examp()
clt.examp(5)
clt.examp(30)
clt.examp(50)
Run the code above in your browser using DataLab