Tossing coins

Toss a bunch of times and look at overall distribution of results. Compare with expected outcome using plots.

Use random number generator to simulate overall distribution

ntoss = 10;
ntries = 1;
result = Table[{n - 1, 0}, {n, 1, ntoss + 1}];

result

Do [   
nheads = 
        0; 
Do[   
If [Random[] < 0.5,  
          nheads = nheads + 1], 
{i, 1, 
          ntoss}
]; 
result[[nheads + 
              1, 2]] = 
        result[[nheads + 1, 2]] + 1, 
{j, 1, 
        ntries}
]

result

plot1 = ListPlot[result, PlotStyle -> PointSize[0.02]]

prob[n_] := 
      ntries*ntoss!/n!/(ntoss - n)!*(1/
            2^ntoss)

plot2 = Plot[prob[n], {n, 0, 10}]

Show[plot1, plot2]