Multiple coin toss

Introduction

A Monte Carlo simulation of the statistical properties of the outcome of tosses of many coins. The probability that an individual coin is heads is p.

Algorithm

For each coin we generate a random number r uniformly in the interval [0, 1]. A coin is heads if r ≤ p. We simulate the toss of many coins and plot a histogram of the number of heads on a single toss and compute the average number of heads and the standard deviation.

Questions

  1. Run the simulation for p = 1/2 and N = 10, 100, and 1000 coins. Describe the qualitative dependence of the histogram on the number of coins.
  2. Estimate the width of the histogram. Make a plot of the estimated width versus N. Compare your estimated values to the standard deviation σ. What is the functional form of this dependence? How does the relative fluctuations σ/<h> depend on N? (The quantity <h> is the mean number of heads in one toss.)
  3. Change the probability of obtaining heads in a single toss to p = 0.8. How does the histogram change? Does the histogram have the same shape?

Java Classes

Updated 27 February 2007.