The Art and Science of Forecasting

Chapter 7

The Casino at Los Alamos

When you cannot calculate the answer, generate the future many times and count what comes out.

Four demonstrations: a simulated cost distribution against single-number budgets, the one over root N price of simulation precision, a Metropolis chain recovering a posterior, and a plan stated as percentiles when its parts can fail together.

Most examples are constructed teaching data, generated with a fixed seed so that every number matches the chapter notebook. Where a demonstration uses a real historical series, such as the annual flow of the Nile, it says so and names the source. Nothing here is a forecast of any real market, product or person.

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).

Equation: total cost C equals component C 1 plus component C 2

Equation: the estimated chance that cost exceeds budget B is the share of the N simulated totals above B

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?

Your prediction

Choose an example

Scroll sideways for the whole figure

Figure: A distribution is more useful than one budget. Histogram of 20000 simulated project costs with a budget line at 74.7; 55.3 percent of totals lie above it.
Budget rule: Sum of component medians
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

  1. Budget: 74.7.
  2. Totals above it: 11057 of 20000.
  3. 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?
500 / 10,000 = 0.05, a 5 percent chance of stockout, as in the chapter's planner example.

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.

Equation: the error is proportional to one over the square root of N

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?

Your prediction

Choose an example

Scroll sideways for the whole figure

Figure: The price of another decimal place. Log-log plot of measured error against draws, following the 1 over root N line; at N = 100 the error is 0.0965.
Draws per estimate: 100
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

  1. sqrt(100) = 10.0000.
  2. Theory: 1 / 10.0000 = 0.1000.
  3. Measured: 0.0965.
  4. 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?
Halving the error needs four times the runs: 4 x 400 = 1600.

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.

Equation: r equals the posterior density at the proposed point theta star divided by the density at the current point theta

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?

Your prediction

Choose an example

Scroll sideways for the whole figure

Figure: A chain that recovers a posterior. Left, the first 700 steps of a Metropolis chain with proposal scale 0.12; right, its histogram after warm-up against the exact Beta(9,5) density; acceptance 0.7205, mean 0.6469.
Proposal scale: 0.12
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

  1. Acceptance: 8646 / 12000 = 0.7205.
  2. Exact mean: 9 / 14 = 0.6429.
  3. 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?
r = 1.5 / 2.0 = 0.75, so it moves with probability 0.75 and stays with probability 0.25.

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.

Equation: the total T is the sum of the components X k

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?

Your prediction

Choose an example

Scroll sideways for the whole figure

Figure: The distribution is the plan. Quantiles of a simulated three-component total with shared factor weight 0.0: P50 177.2, P90 219.9, P95 233.7.
Shared factor weight: 0
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

  1. Mean: 180.0; P90: 219.9.
  2. 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?
264 - 180 = 84 units above the mean.

Chapter 7 source: section "Part Five: The Distribution Is the Plan".