clt.examp: Plot Examples of the Central Limit Theorem

clt.exampR Documentation

Plot Examples of the Central Limit Theorem

Description

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.

Usage

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))

Arguments

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 rnorm

gamma.param

List with parameters passed to rgamma

unif.param

List with parameters passed to runif

beta.param

List with parameters passed to rbeta

Details

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).

Value

This function is run for its side effect of creating plots. It returns NULL invisibly.

Author(s)

Greg Snow 538280@gmail.com

See Also

rnorm, rexp, runif, rbeta

Examples

clt.examp()
clt.examp(5)
clt.examp(30)
clt.examp(50)


TeachingDemos documentation built on May 29, 2024, 5:59 a.m.