This function plots the sample mean as the sample size grows to check whether the sample mean approaches to the population mean.
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 parameter nmax
in ani.options
means the maximum
sample size.
library(animation)
ani.options(interval = 0.01, nmax = 150)
lln.ani(pch = ".")
## chi-square distribution; population mean = df
lln.ani(FUN = function(n, mu) rchisq(n, df = mu), mu = 5, cex = 0.6)
The sample mean approaches to the population mean as the sample size n grows