oopt = ani.options(interval = 0.1, nmax = 150)
op = par(mar = c(3, 3, 1, 0.5), mgp = c(1.5, 0.5, 0), tcl = -0.3)
clt.ani(type = "s")
par(op)
# HTML animation page
ani.options(ani.height = 500, ani.width = 600, nmax = 100,
interval = 0.1, title = "Demonstration of the Central Limit Theorem",
description = "This animation shows the distribution of the sample
mean as the sample size grows.")
ani.start()
par(mar = c(3, 3, 1, 0.5), mgp = c(1.5, 0.5, 0), tcl = -0.3)
clt.ani(type = "h")
ani.stop()
ani.options(oopt)
# other distributions: Chi-square with df = 5
f = function(n) rchisq(n, 5)
clt.ani(FUN = f)
Run the code above in your browser using DataLab