Learning Scientific Programming with Python (2nd edition)

P6.6.1: Coin-flipping simulation

Question P6.6.1

Simulate an experiment carried out ntrials times in which, for each experiment, n coins are tossed and the total number of heads each time is recorded.

Plot the results of the simulation on a suitable histogram, and compare with the expected binomial distribution of heads.