Weak Law of Large Numbers

January 31, 2012

(This article was first published on Knowledge Discovery » R, and kindly contributed to R-bloggers)

1 Description

The weak law of large numbers is a result in probability theory also known as Bernoulli’s theorem. According to the law, the mean of the results obtained from a large number of trials is close to the population mean.

Let be a sequence of independent and identically distributed random variables, each having a mean and variance .

Define a new variable,


By the Chebyshev inequality,

In brief,
as , the sample mean equals the population mean .

2 Simulation in R

The following is the results of simulations(Bi(n,p)).
Moreover, parameter of the population mean is 0.4, sample number is 1,000.

3 Appendix

This is the sample script of R.
Let’s try the Simulation in R with different parameters.

#setting a parameters of Bi(n, p)
n <- 1000
p <- 0.4

df <- data.frame(bi = rbinom(n, 1, p)  ,count = 0, mean = 0)
ifelse(df$bi[1] == 1, df[1, 2:3] <- 1, 0)
for (i in 2 : n){
  df$count[i] <- ifelse(df$bi[i] == 1, df$count[i]<-df$count[i - 1]+1, df$count[i - 1])
  df$mean[i] <- df$count[i] / i

plot(df$mean, type='l',
      main = "Simulation of the Low of Large Numbers",
      xlab="Numbers", ylab="Sample mean")
abline(h = p, col="red")

To leave a comment for the author, please follow the link and comment on their blog: Knowledge Discovery » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)