Demonstration 1 of 4
A distribution is more useful than one budget
If you budget the most likely cost of each part, how often will the project overrun?
Sampling both components 20000 times and adding them gives the distribution of the total. A budget line cuts it in two, and the share to the right is the chance of overrun. Medians do not add: the median total (78.2) is above the sum of the medians (74.7).
Scroll sideways for the whole equation
C is total cost, the sum of two uncertain components C1 and C2 (lognormal, so right skewed). B is the budget. The overrun chance is the share of the N = 20000 simulated totals above B.
Predict first. Budget the sum of the two component medians. Will the chance of overrun be below or above one half?
Choose an example
Scroll sideways for the whole figure
Constructed data: notebook 07 cell 2, 20000 draws of two lognormal cost components.
Calculated values
- Budget rule
- sum of component medians
- Budget
- 74.7
- Simulated totals over budget
- 11057 of 20000
- Chance of overrun
- 55.3 percent
- Mean total
- 83.1
With the budget at the sum of component medians (74.7), 11057 of the 20000 simulated totals exceed it: 11057 / 20000 = 0.5528, a 55.3 percent chance of overrun. Adding the two most likely component costs gives a plan that fails more often than it succeeds, because skewed costs pile their excess in the right tail.
Worked steps
- Budget: 74.7.
- Totals above it: 11057 of 20000.
- Overrun chance: 11057 / 20000 = 0.5528.
Use the idea
Set a project budget or completion date at a stated percentile of a simulated total, such as P80, and say what overrun chance it accepts.
Where the conclusion applies
The two components are independent lognormals chosen for teaching (seed 20260925); the quantiles describe this assumed model, not real project risk. Dependent components would widen the right tail (see the last demonstration).
Check your understanding: In 10,000 simulated demand scenarios, 500 exceed an inventory level. What is the stockout chance at that level?
Chapter 7 source: section "Part Two: Beyond the Weapons Lab".
Demonstration 2 of 4
The price of another decimal place
How fast does Monte Carlo error fall as you add draws?
Each estimate averages N draws, so its spread shrinks as one over the square root of N. On log scales that is a straight line with slope minus one half, and the measured points follow it with sampling scatter.
Scroll sideways for the whole equation
N is the number of draws in one estimate. The error is the root mean squared error of 300 repeated estimates of a known mean (zero, standard deviation one).
Predict first. Going from 100 draws to 1000, by roughly what factor does the error fall?
Choose an example
Scroll sideways for the whole figure
Constructed data: notebook 07 cell 4, 300 repeated normal-mean estimates at each of six sizes.
Calculated values
- Draws N
- 100
- Measured RMSE (300 repeats)
- 0.0965
- Theory 1 / sqrt(N)
- 0.1000
- Measured divided by theory
- 0.97
With N = 100, theory gives 1 / sqrt(100) = 1 / 10.0000 = 0.1000; 300 repeated estimates measure 0.0965. Halving the error needs four times the draws, so each extra decimal place costs a hundred times more simulation. More draws shrink simulation noise only; they cannot repair a wrong model.
Worked steps
- sqrt(100) = 10.0000.
- Theory: 1 / 10.0000 = 0.1000.
- Measured: 0.0965.
- Ratio: 0.0965 / 0.1000 = 0.96.
Use the idea
Decide how many simulation runs to make from the precision the decision needs, and report the simulation error beside the estimate.
Where the conclusion applies
The draws have finite variance; with heavy tails the rate fails. Only 300 repeats per size, so the measured points scatter around the line (seed 20260925).
Check your understanding: A simulation with 400 runs has error about 0.05. How many runs give about 0.025?
Chapter 7 source: section "Part Four: Sampling the Future".
Demonstration 3 of 4
A chain that recovers a posterior
How can a random walk that only compares two probabilities draw samples from a distribution?
Each step proposes a nearby value and accepts it with the ratio of posterior densities, so the normalizing constant cancels. Run long enough, the visited values pile up in proportion to the posterior; the histogram on the right checks that against the exact curve.
Scroll sideways for the whole equation
theta is the current point, theta star the proposed point, drawn from a Gaussian centred on theta with the chosen proposal scale. The target is a Beta(9,5) posterior with exact mean 9 / 14. If r is at least 1 the chain moves; otherwise it moves with probability r.
Predict first. Shrink the proposal scale to 0.01. Will the acceptance rate rise or fall?
Choose an example
Scroll sideways for the whole figure
Constructed data: notebook 07 cell 6, a Metropolis chain on a Beta(9,5) target; scale 0.12 is the notebook's run, 0.01 and 2 restart from the same draws.
Calculated values
- Proposal scale
- 0.12
- Acceptance rate
- 0.7205
- Chain mean
- 0.6469
- Exact mean 9 / 14
- 0.6429
- Chain mean minus exact
- 0.0040
Proposal scale 0.12: 8646 of 12000 proposals accepted, 8646 / 12000 = 0.7205. Mean after warm-up 0.6469 against exact 9 / 14 = 0.6429, an error of 0.6469 - 0.6429 = 0.0040. Moderate steps mix well and the histogram follows the exact curve. A high acceptance rate is not the goal; exploration is.
Worked steps
- Acceptance: 8646 / 12000 = 0.7205.
- Exact mean: 9 / 14 = 0.6429.
- Error: 0.6469 - 0.6429 = 0.0040.
Use the idea
When a posterior has no closed form, run a Metropolis chain, discard a warm-up, and check mixing with traces and several chains before trusting its averages.
Where the conclusion applies
The proposal is symmetric, so the Hastings correction is not needed. One chain and a fixed 2000-step warm-up are teaching choices (seed 20260925); serious use needs several dispersed chains and effective sample sizes.
Check your understanding: The current point has posterior density 2.0 and the proposal has 1.5. With what probability does the chain move?
Chapter 7 source: section "Part Four: Sampling the Future".
Demonstration 4 of 4
The distribution is the plan
When the parts of a plan can go wrong together, what happens to the number you should commit to?
Each run draws the three components, adds them, and records the total; 10000 runs give the quantile curve. When components move together their bad cases coincide, so the upper quantiles climb while the mean does not change.
Scroll sideways for the whole equation
T is the total of three lognormal components X1 to X3 (labor mean 100 sd 25, materials 60 sd 15, shipping 20 sd 8). The shared factor weight ties their latent draws together: 0 is independent, 0.9 strongly dependent.
Predict first. Raise the shared factor weight from 0 to 0.9. What happens to the P90?
Choose an example
Scroll sideways for the whole figure
Constructed data: the companion's example cost components (labor, materials, shipping) run through the chapter's Monte Carlo tool with 10000 draws.
Calculated values
- Shared factor weight
- 0.0
- Mean total
- 180.0
- Monte Carlo error of the mean
- 0.30
- P50
- 177.2
- P90
- 219.9
- P95
- 233.7
With shared factor weight 0.0, the mean total is 180.0 (the components' means add to 180) but the P90 is 219.9, so 219.9 - 180.0 = 39.9 of contingency is needed for a 90 percent plan. Dependence leaves the mean alone and moves the tail, which a point plan never shows.
Worked steps
- Mean: 180.0; P90: 219.9.
- Contingency for P90: 219.9 - 180.0 = 39.9.
Use the idea
State a plan as percentiles (85 percent by March, 95 percent by April) and ask which inputs share a common cause before trusting independent simulations.
Where the conclusion applies
Lognormal components with the stated means and spreads, dependence through one shared normal factor, seed 417 as in the companion's example configuration. The quantiles describe these assumptions, not measured risk.
Check your understanding: A plan's simulated mean is 180 and its P95 is 264. How much contingency does a 95 percent commitment need?
Chapter 7 source: section "Part Five: The Distribution Is the Plan".