0

I understand the Law of Large Numbers, but can't find any simple example simulating it in R. Can someone give me an example of this law in R?

Regards!

Community
  • 1
  • 1
fatboat
  • 31
  • 1
  • 2
  • Please consider reading up on [ask] and how to produce a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Currently, your question is unanswerable. – Heroka Oct 27 '15 at 16:56

1 Answers1

3

This question will likely be closed, but perhaps something like this will suffice:

die <- 1:6
roll <- function(n) {
  mean(sample(die, size = n, replace = TRUE))
}

plot(sapply(1:1000, roll), type = "l", xlab = "# of dice", ylab = "average")
abline(h = 3.5, col = "red")

Plot

JasonAizkalns
  • 20,243
  • 8
  • 57
  • 116