Central Limit Theorem Example

What has coin tossing got to do with a Gaussian distribution?

<<Histograms`

Each trial will consist of tossing a fair coin ntosses times and counting the number of heads.  Then we will repeat this trial many times.  We'll do this by selecting 0's and 1's randomly and calling the 1's heads.  So after a single trial, all we have to do is add up the numbers and that will tells us the number of heads tossed.  After each trial we'll save the result in a table called trialresults.

ntosses = 100
ntrials = 10000
trialresults = Table[0,{i,ntrials}];
Do[
heads = Table[Random[Integer,{0,1}],{j,ntosses}];
trialresults[[i]] = Sum[heads[[j]],{j,ntosses}],
{i,1,ntrials}]

Histogram[trialresults]