Demonstration of the Law of Large Numbers
The Law of Large Numbers (LLN) basically states that the average obtained from a large number of trials should be close to the expected value, and will tend to become closer as more trials are performed.
The function lln.ani()
in the animation package provides us a
visualization method for the LLN. It plots the sample mean as the sample size grows to check
whether the sample mean approaches to the population mean. Here we make an animation with the
Chi-squared distribution as the population
distribution.
library(animation)
ani.options(interval = 0.3)
lln.ani(FUN = function(n, mu) rchisq(n, df = mu), mu = 5, cex = 0.6)
References
- This article was reproduced from vistat
Published
18 April 2013