Approximating a Normal Distribution by Rolling Dice

Jon Leete

Executive Summary

Rolling dice repeatedly produces a distribution of mean die rolls. Rolling a single die yields a uniform distribution; rolling more dice, a progressively more normal distribution:

plot of chunk execSummPlot

The application discussed herein lets the user experiment with this effect dynamically.

Application

This application illustrates the Central Limit Theorem, introduced early in the Coursera Data Science track, by showing that the means of a random uniform distribution converge to a normal distribution as the sample size grows.

The application generates random samples of uniformly-distributed random numbers. The user selects the sample sizes and number of samples; it is up to the user to observe the phenomemon for him/herself by varying these parameters.

200

The application is available to run at: https://jleete97.shinyapps.io/normalhist

and the GitHub repository for the code is at: https://github.com/jleete97/normalhist

Theory: Uniform Distribution

Let's simulate rolling one die many times, and look at the distribution of results:

set.seed(10002); v1 <- rep(0, 1000)
for (i in 1:1000) {
    v1[i] <- trunc(runif(n = 1, min = 1, max = 6 + 1))
}

plot of chunk oneDieHist

Unsurprisingly, the distribution looks roughly uniform. Each result, 1-6, comes up about 1/6 of the time.

Theory: Distribution with Many More Samples

With 15 dice, the results are much more normally distributed, as the Central Limit Theorem would suggest.

set.seed(10005); v15 <- rep(0, 1000)
for (i in 1:1000) {
    r <- trunc(runif(n = 15, min = 1, max = 6 + 1))
    v15[i] <- mean(trunc(r))
}

plot of chunk fifteenDiceHist