Sometimes there are probability questions that are difficult to find theoretically or where actually conducting an experiment is impractical. This is where simulation comes in handy. If you want to know what happens when you explode a nuclear bomb, well, that's not something you can afford to do very often, even if you could manage to obtain of a nuclear device in the first place. Let's say you want to study the evolution of a species over a 1000 year period; that's not something you can wait around for.
Computers can be used to simulate those conditions for us much quicker and cheaper than we could do it (if we could do it at all). There are computer software packages that will perform very complicated simulations. You can also use computers to perform simple simulations (what we're going to do) but you don't have to have a computer to perform simulations, they can be sometimes be done with everyday materials such as coins or dice.
When you are through with this lesson, you'll be able to do the following tasks.
There are two major types of simulation that we're going to look at.
When asked to find the probability of something, you want to conduct an experiment many times (the more times the better), and record the outcomes of each experiment. If you're only looking for one probability (see Great Birthday Problem), then you can classify outcomes as success or failure, but if you're looking for more than one probability (see Craps) it will be useful to record the individual outcomes.
Once you have finished collecting the data by repeating the experiment several times, you can find the empirical probability or relative frequency by taking the number of successes divided by the number of trials. Sometimes you will see this written as the number in the event divided by the number in the sample space, but the number of successes divided by the number of trials works just as well and is simpler to remember.
Sometimes you're asked to find the average number of times it will take to accomplish something. For example, how many moves does it take to win Chutes & Ladders or how many numbers must be called out before someone yells "BINGO!"?
The key to working this problems is to simulate the problem and record the number of times it takes to finish the game or experiment. Repeat the whole game many times (the more the better) and then when you're all done, find the mean (average) of the numbers you have recorded. This is the expected value.
Sometimes the expected value can be found theoretically, but other times it is just impossible or impractical to do theoretically.
The important thing to remember when designing simulations is that you have to make it realistic or the simulation is not valid. For instance, if you want to simulate births of children, there are two possibilities, boy or girl, and both are equally likely. You need to find some way of simulating that experience ... and flipping a coin immediately comes to mind because there are also two outcomes that are equally likely. Don't roll a die to simulate births because there are six outcomes possible. However, if you rolled a die and decided a roll of 1, 2, or 3 is a boy and a 4, 5, or 6 is a girl, then that would be okay because there are two outcomes, each equally likely.
If you want to simulate birthdays, you can't roll a die or flip a coin. There are 365 birthdays, not including leap day, in a year and so you would need something that generated values between 1 and 365. In this case, you could write the numbers from 1 to 365 on pieces of paper and stick them in a hat and randomly select them, replacing the paper and reshuffling the papers after each draw.
On the other hand, there is the good old trusty random number generator on the calculator or computer. This is highly recommended for all but the simplest simulations because of speed. Every programming language has a random number generator and even applications like spreadsheets include them, too. They usually generate random numbers with a uniform distribution between 0 and 1 (including 0, but not including 1), so they need transformed into something useful.
The command to generate the random integer varies from language to language, but it usually goes something like this. n = int ( a * rand() + b ) where a is the number of values to generate and b is the starting value.
Here are some examples:
If you want to simulate things where the outcomes aren't equally likely, then you need to make adjustments. For example, in craps, you roll 2 dice and look at the sum. To simulate this, you would either generate to uniform integers between 1 and 6 or you would generate numbers between 1 and 36 and assign them as 1=1, 2 thru 3=2, 4 thru 6=4, 7 thru 10=5, etc., so that the probabilities match what the probabilities of the sums are.
If the outcomes aren't uniformly distributed, but have some other distribution like normal or poisson, then you could use a computer algebra system to generate the numbers and perform the simulation.
Here are some problems to help you get a feel for simulation techniques. Go ahead and work through each one and when you're done, come back and take a quiz.
Take a little quiz to determine how well you have learned about simulation.
Go to James Jones' website.