Learn R Programming

animation (version 0.2-0)

lln.ani: Demonstration of Law of Large Numbers

Description

This function plots the sample mean as the sample size grows to check whether the sample mean approaches to the population mean.

Usage

lln.ani(FUN = rnorm, mu = 0, np = 30, pch = 20, 
    control = ani.control(interval = 0.3), ...)

Arguments

FUN
a function to generate random numbers from a certain distribution
mu
population mean; passed to FUN
np
times for sampling from a distribution (not the sample size!); to examine the behaviour of the sample mean, we need more times of sampling to get a series of mean values
pch
symbols for points; see Details
control
control parameters for the animation; see ani.control
...
other arguments passed to ani.control

Value

  • None (invisible `NULL').

Details

np points are plotted to denote the distribution of the sample mean; we will observe that the range of the sample mean just becomes smaller and smaller as the sample size increases and ultimately there will be an obvious trend that the sample mean converges to the population mean mu. The argument nmax in control means the maximum sample size.

References

George Casella and Roger L. Berger. Statistical Inference. Duxbury Press, 2th edition, 2001.

Examples

Run this code
lln.ani()

# save the animation in HTML pages
ani.start()
lln.ani(saveANI = TRUE, interval = 0.2, width = 600, height = 500)
ani.stop()

Run the code above in your browser using DataLab