A small test suite that solves ten probability puzzles exactly and checks each answer against a million simulated trials.
Pick ten puzzles from across the module, such as a poker hand, a positive test, the three doors, matching hats, 23 birthdays, and gambler's ruin from $10 to $20 at 49% a bet.
Solve each one exactly, by counting, conditioning or first-step analysis, and write the answer as a Python Fraction.
Simulate each with NumPy over a million trials, with no Python loop over the trials, and report the estimate with its standard error.
Write one pytest test per puzzle that passes when the exact answer sits within three standard errors of the simulation.
Simulate 1,000 bettors making 1,000 even-money bets on a coin that wins 55% of the time, at full, half and double the Kelly fraction, and plot their median wealth.
How you'll know it worksTen tests that pass with a fixed seed, and a chart where half Kelly's median wealth ends above double Kelly's.
Python with NumPy, matplotlib and pytest. There's no data to download, and it runs in seconds. Uses lessons 01 to 12.
Project: Interview puzzles, checked by simulation
From insideout, Probability: A small test suite that solves ten probability puzzles exactly and checks each answer against a million simulated trials.
Steps:
1. Pick ten puzzles from across the module, such as a poker hand, a positive test, the three doors, matching hats, 23 birthdays, and gambler's ruin from $10 to $20 at 49% a bet.
2. Solve each one exactly, by counting, conditioning or first-step analysis, and write the answer as a Python Fraction.
3. Simulate each with NumPy over a million trials, with no Python loop over the trials, and report the estimate with its standard error.
4. Write one pytest test per puzzle that passes when the exact answer sits within three standard errors of the simulation.
5. Simulate 1,000 bettors making 1,000 even-money bets on a coin that wins 55% of the time, at full, half and double the Kelly fraction, and plot their median wealth.
How you'll know it works: Ten tests that pass with a fixed seed, and a chart where half Kelly's median wealth ends above double Kelly's.
Runs on: Python with NumPy, matplotlib and pytest. There's no data to download, and it runs in seconds.
Help me build this on my machine, one step at a time. Ask what I've tried first, give hints before full answers, and check my work against "How you'll know it works".