Monte Carlo Simulation
Tossing a Coin
Monte Carlo simulation is particularly useful when you want to predict the overall outcome
of a series of related events when you only know the statistical probability of the
outcome of each component event.
The simplest such situation must be the tossing of a coin. Any individual event will
result in the coin falling with one side or the other uppermost (heads or tails).
However, common sense tells us that, if we tossed it a very large number of times, the
total number of heads and tails should become increasingly similar. We could
simulate this by using a random number between 1 and 100 to decide which side would be
uppermost, giving a 50% chance of it falling on either side by making heads any
number below or equal to 50 and tails any above 50.
This element of chance at each event is where the name Monte Carlo,
synomymous with games of chance, comes from.
The working simulation
Here is a working example of the coin-tossing simulation with lots of information in
addition to which side the coin lands.
Click on one of the option buttons to select how many times you want the coin
tossed - I have limited the range to 100 000 times simply because Javascript is not too
fast.
If you select the whole series option, the program will work through 100,000 tosses
and will eventually display the running totals it recorded for the smaller samples on the
way.
Source and permission for noncommercial use: Monte Carlo Introduction |