Simulations and Conditional Probability
Theory
A simulation imitates a chance situation with coins, dice, random digits or a spreadsheet, and the relative frequency of the results estimates a probability. This Year 10A maths page shows how to estimate a conditional probability from simulated trials, combine results, judge whether a device is fair, and check surprising results such as the three-door game and repeated birthdays against the theory. Curriculum: VC2M10P01 / AC9M10P02.
The frequency of an outcome is the number of times it happened. The relative frequency is that frequency divided by the total number of trials. It is also called the experimental or observed probability.
The theoretical probability is the probability expected under fair conditions, worked out from equally likely outcomes. For a fair die, \(P(6) = \dfrac{1}{6}\).
Relative frequency and theoretical probability are rarely exactly equal. With more trials, the relative frequency usually gets closer to the theoretical probability, so more trials give a better estimate.
If, after many trials, the relative frequency is far from the theoretical probability, the object may be biased (not fair).
A simulation imitates a chance experiment with something easier to repeat: coins, dice, spinners, random digits or a spreadsheet formula such as =RANDBETWEEN(1,10). Each outcome of the simulation stands for an outcome of the real situation, with the same probability.
A simulation can also estimate a conditional probability \(P(B\mid A)\). Keep only the trials in which \(A\) happened, and find the fraction of those in which \(B\) also happened. The trials without \(A\) are ignored.
Simulations are useful when the exact working is long or when the answer is counterintuitive (it surprises most people), such as the three-door game or the chance that two people in a group share a birthday. They are also used to make decisions about stock, insurance, queues and the spread of a virus.
From an experiment or a simulation:
Estimating a conditional probability from trials:
=RANDBETWEEN(1,6) rolls a die.How to work with relative frequency
- Find the number of trials. In a table, add the whole frequency column.
- Find the frequency of the event. Add every row that fits it.
- Divide frequency by trials. Give a decimal, or simplify the fraction.
- Predict by multiplying a relative frequency by a new number of trials.
- Compare with the theoretical probability. A small gap is normal; a big gap after many trials suggests bias.
How to estimate a conditional probability by simulation
- Match each stage to a device with the same probabilities. If the second stage depends on the first, use a different rule for each first result.
- Define one trial, such as a pair of digits for two days, and run many trials.
- Keep only the trials where the condition happened, and count them.
- Count how many of those also have the event, and divide.
- Compare with the theoretical value. Few trials meet the condition, so the estimate can be far off; more trials make it more reliable.
Other question types
- Counts given as a table: a simulated two-way table works like a real one. "Given" picks one row or column as the total.
- The three-door game: sticking wins only if the first pick was right. Switching wins if the first pick was wrong (and, with more doors, you then switch to the car).
- Explaining a gap: say how many trials met the condition, and that larger simulations usually get closer.
(i) Find each class's relative frequency of red.
(ii) Combine the results.
(iii) How many reds would a fair spinner give in \(300\) spins? Is the spinner fair?
(iv) Predict the number of reds in \(900\) spins.
| \(\text{A}\) | \(:\) | \(\dfrac{50}{120}\approx \boldsymbol{0.417}\) |
| \(\text{B}\) | \(:\) | \(\dfrac{70}{180}\approx \boldsymbol{0.389}\) |
(ii) Add the reds and add the spins.
| \(\text{combined}\) | \(=\) | \(\dfrac{50+70}{120+180}\) |
| \(\) | \(=\) | \(\dfrac{120}{300}=\boldsymbol{0.4}\) |
(iii) Fair: \(\dfrac{1}{3}\times 300=\boldsymbol{100}\) reds. There were \(120\), a large gap over \(300\) spins, so the spinner is probably biased towards red.
(iv) Use the combined estimate: \(0.4\times 900=\boldsymbol{360}\) reds.
38 07 52 91 26 44 13 75 60 29 84 31 57 02 96 18
(i) Estimate \(P(\text{wins Sunday}\mid\text{wins Saturday})\) and compare with \(0.7\).
(ii) Estimate \(P(\text{won Saturday}\mid\text{wins Sunday})\).
(i) Saturday wins (first digit \(0\)β\(4\)): 38, 07, 26, 44, 13, 29, 31, 02, 18. That is \(9\) trials. Sunday also won (second digit \(0\)β\(6\)): 26, 44, 13, 31, 02, which is \(5\).
| \(P\) | \(\approx\) | \(\dfrac{5}{9}\approx \boldsymbol{0.56}\) |
This is well below \(0.7\) because only \(9\) trials meet the condition.
(ii) Now the condition is a Sunday win. Sunday wins: 26, 44, 13, 31, 02 (after a Saturday win) and 52, 91, 60 (after a loss, second digit \(0\)β\(3\)). That is \(8\) trials, and \(5\) of them had a Saturday win.
| \(P\) | \(\approx\) | \(\dfrac{5}{8}=\boldsymbol{0.625}\) |
The theoretical value is \(\dfrac{0.5\times 0.7}{0.5\times 0.7+0.5\times 0.4}=\dfrac{7}{11}\approx 0.636\), close to the estimate.
(i) Estimate \(P(\text{flagged}\mid\text{spam})\).
(ii) Estimate \(P(\text{spam}\mid\text{flagged})\), correct to \(2\) decimal places.
(iii) Explain why the two answers are different.
(i) The condition is spam: \(80\) emails, \(72\) flagged.
| \(P(\text{F}\mid\text{S})\) | \(\approx\) | \(\dfrac{72}{80}=\boldsymbol{0.9}\) |
(ii) The condition is flagged: \(72+21=93\) emails, and \(72\) of them are spam.
| \(P(\text{S}\mid\text{F})\) | \(\approx\) | \(\dfrac{72}{93}\approx\boldsymbol{0.77}\) |
(iii) The denominators are different groups. Genuine emails are far more common, so even a few wrongly flagged genuine emails (\(21\)) make up a real share of all flagged emails. Mixing up \(P(A\mid B)\) and \(P(B\mid A)\) is a common mistake.
(i) Estimate the probability of a repeat.
(ii) Find the theoretical probability, correct to \(3\) decimal places.
(iii) Why do most people guess too low?
| \(P(\text{repeat})\) | \(\approx\) | \(\dfrac{21}{30}=\boldsymbol{0.7}\) |
(ii) Use the complement. For all five to be different, each new person must avoid the numbers already chosen.
| \(P(\text{all different})\) | \(=\) | \(\dfrac{10\times 9\times 8\times 7\times 6}{10^5}\) |
| \(\) | \(=\) | \(0.3024\) |
| \(P(\text{repeat})\) | \(=\) | \(1-0.3024\) |
| \(\) | \(\approx\) | \(\boldsymbol{0.698}\) |
(iii) People think about one person matching one other person. But \(5\) people make \(10\) different pairs, and any pair can match, so a repeat is likely. The simulation (\(0.7\)) agrees well.
Common pitfalls
Frequently asked questions
What is a simulation in probability?
A simulation imitates a chance situation with a device that is easy to repeat, such as coins, dice, random digits or a spreadsheet, where each result has the same probability as the real outcome.
How do you estimate a conditional probability from a simulation?
Count the trials in which the condition happened. Of those, count the trials in which the event also happened, and divide.
Why do more trials give a better estimate?
Over many trials the relative frequency settles close to the true probability. With few trials, chance alone can push it far away.
Should you switch in the three-door game?
Yes. Switching wins whenever your first pick was wrong, which has probability \(\dfrac{2}{3}\). Sticking wins only with probability \(\dfrac{1}{3}\).
What is the difference between relative frequency and probability?
Relative frequency is what happened in actual trials. Theoretical probability is what should happen in the long run. They are rarely exactly equal.