clt.ani {animation}R Documentation

Demonstration for the Central Limit Theorem

Description

First of all, a number of obs observations are generated from a certain distribution for each variable Xi (i = 1, 2, ..., n), then the sample means are computed, and at last the density of these sample means is plotted as the sample size increases.

Usage

clt.ani(obs = 100, FUN = runif, control = ani.control(interval = 0.1), 
    ...)

Arguments

obs the number of sample points to be generated from the distribution
FUN the function to generate n random numbers from a certain distribution
control control parameters for the animation; see ani.control
... other arguments passed to ani.control

Details

As long as the conditions of the Central Limit Theorem (CLT) are satisfied, the distribution of the sample mean will be approximate to the Normal distribution when the sample size n is large enough no matter what is the original distribution. The largest sample size is defined by control$nmax.

Value

None.

Author(s)

Yihui Xie

References

E. L. Lehmann, Elements of Large-Sample Theory. Springer-Verlag, New York, 1999.

See Also

density

Examples

clt.ani()

## Not run: 
 
# HTML animation page
ani.start()
clt.ani(saveANI = TRUE, height = 500, width = 600)
ani.stop()

## End(Not run)

# other distributions: Chi-square with df = 5 
f = function(n) rchisq(n, 5) 
clt.ani(FUN = f) 

[Package animation version 0.2-0 Index]