clt.examp | R Documentation |
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))
n |
size of the individual samples |
reps |
number of samples to take from each distribution |
nclass |
number of bars in the histograms |
norm.param |
List with parameters passed to |
gamma.param |
List with parameters passed to |
unif.param |
List with parameters passed to |
beta.param |
List with parameters passed to |
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).
This function is run for its side effect of creating plots. It returns NULL invisibly.
Greg Snow 538280@gmail.com
rnorm
, rexp
, runif
,
rbeta
clt.examp()
clt.examp(5)
clt.examp(30)
clt.examp(50)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.