Illustrating the Central Limit Theorem

by Joshua R. Davis, jdavis@carleton.edu

A Uniform Distribution

The following code illustrates the Central Limit Theorem for the sampling distribution of the mean of a set of n rolls on a six-sided die. Click anywhere in the code block below; then press Enter (not Return) to execute it. Execute it repeatedly to see how the sampling distribution changes. Change the value of n and see what happens.

values = {1, 2, 3, 4, 5, 6};
probs = {1/6, 1/6, 1/6, 1/6, 1/6, 1/6};
n = 1000;
distrib = Table[Mean[RandomChoice[probs -> values, n]], {1000}];
Histogram[distrib]

A Pretty Nasty Distribution

Imagine rolling a six-sided die. You get 1 point if you roll a 1, 2 points if you roll a 2 or 3, and 5 points if you roll a 4, 5, or 6. Draw the probability distribution. It is asymmetric and bimodal. Execute the code below for various choices of n.

values = {1, 2, 5};
probs = {1/6, 2/6, 3/6};
n = 1000;
distrib = Table[Mean[RandomChoice[probs -> values, n]], {1000}];
Histogram[distrib]

Even Nastier Now

Try this one with low values of n, such as 1, 2, 3, 4, and then try larger values such as 100 and 1000.

values = {1, 2, 3, 4, 100}
probs = {1/10, 1/10, 1/10, 1/10, 6/10}
n = 1;
distrib = Table[Mean[RandomChoice[probs -> values, n]], {1000}];
Histogram[distrib]