Weak Law of Large Numbers

January 31, 2012
By

[This article was first published on Knowledge Discovery » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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,

Then,

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

#dataframe
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
}

#graph
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 about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.



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

Sponsors

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)