Start here · Essential guide
Simulating Probability with Simple Code
How a short program can estimate chances by repeating a random experiment many times, and how to use it to check hand calculations and spot modelling mistakes.
Methods and Tools
Checking probability answers with simple simulations and code.
Start here · Essential guide
How a short program can estimate chances by repeating a random experiment many times, and how to use it to check hand calculations and spot modelling mistakes.
Outline a short program that plays the Monty Hall game many times, and see why switching doors wins about two thirds of the time while staying wins about one third.
Why simulation error shrinks roughly with the square root of the number of runs, with checked examples showing what 100, 10,000 and 1,000,000 trials typically give.
How computers produce deterministic but random-looking numbers: what a seed is, what a period means, and a tiny hand-checked generator that shows the idea.
The correct way to shuffle a list in code, why the common swap-with-anyone version is biased, and a simple counting argument that shows the difference.
Simulate a coin-toss random walk to see why running totals wander far from zero, and how typical distance grows with the square root of the number of steps.
Build a short Python dice roller, count the results, and compare simulated frequencies with the exact values for one die and for the total of two dice.
Model a drop chance with and without a pity timer that guarantees a drop after a fixed number of tries, using checked illustrative numbers and short code.
Model coin tosses, dice and simple chance questions with spreadsheet random functions such as RAND and RANDBETWEEN, and learn how to read and freeze the results.
How to turn simulated outcomes into a histogram, choose sensible bins, and read the shape: symmetric, skewed or bell-shaped, with a short Python plotting example.
Related topics