Vistat

a reproducible gallery of statistical graphics

Demonstration of the Law of Large Numbers

  • Lijia Yu (yu@lijiayu.net / GitHub / Twitter) A master candidate majoring in Bioinformatics at Beijing Institute of Genomics.

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)

Meta

Keywords: Categories: Reviewer: You can find the R Markdown source document in the vistat repository on GitHub.