What could happen? Scenarios, Monte Carlo and global sensitivity
Sample five uncertain inputs with a Latin hypercube, run a delay-cost model 1,000 times and rank the inputs by influence
The developer's cost of a 24-month wait, 1,000 runs (illustrative)
- One number: at the base inputs, a 24-month wait costs the developer $171.1M in present value, and other customers $14.7M.
- Scenarios, with no chance attached: the developer's cost is $88.8M, $171.1M and $247.3M for waits of 12, 24 and 36 months.
- One at a time: the margin swings the developer's cost most, from $137.8M to $204.4M; capital and the discount rate swing it by $28.5M and $28.0M.
- Stacked corners: every input at its low-cost end gives $111.8M; at its high-cost end, $234.7M.
- Sampling 10 runs with seed 7: plain random leaves 4 of 10 margin slices and 3 of 10 discount-rate slices empty; a Latin hypercube leaves none.
- 1,000 Latin hypercube runs: median $170.3M; 80% of runs from $140.9M to $200.1M; the runs span $120.0M to $230.2M.
- Near a corner (margin, capital and discount rate all in the same outer tenth of their ranges): 2 runs; a chance of 0.1³ per corner predicts 2.
- Monte Carlo error over 20 seeds: P90 $200.1M ± $1.3M (two standard errors) with 1,000 runs, ± $4.7M with 100.
- A chance under these inputs: above $200M, 0.0% of runs at 12 months, 10.1% at 24 and 92.9% at 36.
- Spearman's rank correlation with the developer's cost: margin 0.86 (rank 1); then capital 0.38 and discount rate 0.31 (tied, rank 2–3); with other customers' cost: upgrades 0.81 (rank 1); then never arrives 0.54 (rank 2).
- Narrow the margin's range to ± $5,000: capital 0.64 and discount rate 0.59 (tied, rank 1–2), and the margin (0.47) ranks 3.
The summaries on this page
| Summary | Value |
|---|---|
| Runs | 1,000 (Latin hypercube, seed 7) |
| Median | $170.3M |
| P10 and P90 | $140.9M and $200.1M |
| P90, Monte Carlo error | ± $1.3M (2 standard errors, 20 seeds) |
| Share above $200M, 24 months | 10.1% ± 1.0 points (2 standard errors) |
| Corners | $111.8M and $234.7M |
Text version of the histogram
| Cost, from | up to | Runs |
|---|---|---|
| $115.0M | $120.0M | 1 |
| $120.0M | $125.0M | 11 |
| $125.0M | $130.0M | 13 |
| $130.0M | $135.0M | 28 |
| $135.0M | $140.0M | 37 |
| $140.0M | $145.0M | 58 |
| $145.0M | $150.0M | 49 |
| $150.0M | $155.0M | 61 |
| $155.0M | $160.0M | 76 |
| $160.0M | $165.0M | 73 |
| $165.0M | $170.0M | 89 |
| $170.0M | $175.0M | 73 |
| $175.0M | $180.0M | 67 |
| $180.0M | $185.0M | 67 |
| $185.0M | $190.0M | 65 |
| $190.0M | $195.0M | 69 |
| $195.0M | $200.0M | 62 |
| $200.0M | $205.0M | 30 |
| $205.0M | $210.0M | 36 |
| $210.0M | $215.0M | 13 |
| $215.0M | $220.0M | 14 |
| $220.0M | $225.0M | 6 |
| $225.0M | $230.0M | 1 |
| $230.0M | $235.0M | 1 |
With JavaScript on, you run these studies yourself, step by step.
- Toy: the waiting load of case file CF7, 100 MW: illustrative round numbers in one price level (no inflation). Other customers pay the utility's costs (no large-load tariff); no bridge power.
- Ranges: invented around CF7's values, each uniform and drawn independently; the wait is a scenario of 12, 24 or 36 months.
- Accounts: present values, each run at its own discount rate, month by month; the two accounts are never added.
- Sampling: Latin hypercube, seed 7, generator mulberry32; percentiles by linear interpolation, as in K5; Monte Carlo error from 20 repeats with seeds 1 to 20.
About 35 guided minutes in ten steps. Every run is computed in your browser; nothing is sent anywhere.
Build it in Python · notebook lab, about 45 minutes, then 60 minutes of practice
The same toy and the same seeded Latin hypercube in NumPy: assert cells check your runs against the page, then SciPy's own Latin hypercube, Spearman's ρ and variance shares (Sobol indices) take over.
- Download the notebook and the lesson data into one folder (in Colab, upload the data with the folder icon).
- Open it in Google Colab (File → Upload notebook) or locally with Python 3, NumPy and SciPy 1.9 or later.
- Run all cells (a few seconds), then try the five practice tasks at the end.
What you just did, as diagrams
- Scenario
- A what-if set of inputs; here the wait, 12, 24 or 36 months, each given no probability.
- One at a time
- Swing one input across its range, the others fixed: a tornado chart; it gives no chances.
- Distribution
- How likely each value of an input is; uniform here, every value in its range equally likely.
- Latin hypercube
- Cuts every range into N equal slices and draws exactly once in each, for all inputs at once.
- Monte Carlo error
- How far an estimate moves with another seed: report it with the run count.
- Rank correlation
- Spearman's ρ ranks inputs by influence within the assumed ranges, not in the world.
Go deeper · ModelerThe formulas: the toy, the Latin hypercube, ρ and the Monte Carlo error
- The toy. With \(i = (1+r)^{1/12} - 1\) and \(A = \frac{1 - (1+i)^{-\tau}}{i}\), the developer’s cost is \(D = (m P + K i)\,A\) and other customers’ is \(R = U i A + \min(0.5,\, h\tau)\, U (1+i)^{-\tau}\).
- Symbols. \(m\) margin ($ per MW a month), \(P\) = 100 MW, \(K\) idle capital ($), \(r\) yearly discount rate, \(U\) upgrade cost ($), \(\tau\) the wait (months).
- The never-arrives chance. \(h\) is in percentage points added a month, not compounded: \(h\tau\) = 24 × 0.5 points = 12%, capped at 50%.
- Latin hypercube. Run \(a\)’s draw of input \(j\) is \(u_{a,j} = (\pi_j(a) + \xi_{a,j})/N\), with \(\pi_j\) a random ordering of \(0, \dots, N-1\) and \(\xi\) uniform on \([0, 1)\); the value is \(\text{lo} + u\,(\text{hi} - \text{lo})\).
- Spearman’s ρ. The correlation of the ranks; with no ties, \(\rho = 1 - \frac{6 \sum_a d_a^2}{N (N^2 - 1)}\), where \(d_a\) is run \(a\)’s rank of the input minus its rank of the cost.
- Monte Carlo error. The standard error of an estimate is the standard deviation of that estimate over 20 repeats with other seeds; 20 repeats make the error itself rough, about ± 16%.
- What the hypercube buys. Over 20 seeds, the mean cost of 1,000 runs scatters by $0.03M with a Latin hypercube and $0.80M with plain random draws (one standard error); the P90, by $0.65M and $0.80M.
- A share’s error. For plain random draws, K5’s \(\sqrt{p(1-p)/N}\) gives 0.95 points for the 10.1% above $200M; the Latin hypercube repeats scatter by 0.52 points.
- Near a corner. With continuous inputs, an exact corner has zero chance. Near one (the margin, capital and discount rate all in the same outer tenth of their ranges) has 0.1³ = 0.1% per corner, so 1,000 runs expect 2; seed 7 has 2, both at the high-cost end.
Go deeper · ModelerWhat a rank correlation misses, and what comes next
- Monotone effects only. ρ reads how consistently the cost rises or falls with an input. An input that matters only through another (an interaction) or pushes the cost up and then down can show ρ near 0.
- Variance shares. Sobol indices split the variance of the cost among the inputs and their interactions; with \(k\) inputs they need about \(N(k+2)\) runs. The lab estimates them for this toy.
- Inputs that move together. Draw them with a stated rank correlation (Iman and Conover’s method; the lab’s practice task 3 uses a simplified two-input version), or sample whole records from data, as K5 suggests.
- Slow models. When 1,000 runs take too long, a fast stand-in fitted to a few runs does the sampling (M9); deciding before the uncertainty resolves is M8.
Check yourself, then try it
Myth or fact? “A P90 of $200.1M means a 10% chance that the real wait costs more.”
- Myth
- Fact
Answer
Myth. 10% of runs cost more, under the assumed ranges, uniform shapes and independent inputs. Change any of those and the P90 moves.
Myth or fact? “With 1,000 runs, a Monte Carlo answer is exact.”
- Myth
- Fact
Answer
Myth. Over 20 seeds, the P90 of 1,000 runs scatters by ± $1.3M (2 standard errors). More runs shrink that; no run count fixes a wrong range.
Myth or fact? “The input with the largest rank correlation matters most in the real world.”
- Myth
- Fact
Answer
Myth. ρ ranks inputs within the ranges you assumed: narrow the margin's to ± $5,000 and it drops from first to third.
50 of 1,000 random runs exceed a budget. The share, with its standard error from K5's formula?
- 5.0% ± 0.7 points
- 5.0% ± 5.0 points
- 50% ± 1.6 points
- 5.0%, exactly
Answer
5.0% ± 0.7 points: √(0.05 × 0.95 ÷ 1,000) = 0.0069, about 0.7 percentage points.
A report says only “P90 cost: $200M”. What should it add first?
- More decimal places
- The cost at the base inputs
- Ranges and shapes, run count, seed and scatter
- The name of the computer it ran on
Answer
The inputs, the run count, the seed and the scatter: without them nobody can judge or repeat the P90.
Try it yourself with open code
Optional, about 30 minutes; needs Python 3.10 or later (lesson B2).
- Clone and install the repository (its README's quick start), then write the illustrative files:
code-delay example my_scenario.json --grid grid.json --ranges ranges.json. - Run
code-delay lhs my_scenario.json ranges.json --samples 500 --seed 1 --out-dir outputs/lhs; openrank_correlations.csv. - Rerun with
--seed 2. Do any two inputs swap places? Then treat them as tied, as step 9 does.
code-delayed-energization: public example repository · MIT licence · illustrative inputs.
Numbers, sources and what’s next
Numbers to remember
| Number | What it means | Source |
|---|---|---|
| $200.1M ± $1.3M | The toy's P90 for a 24-month wait: 1,000 Latin hypercube runs, seed 7, ± 2 standard errors over 20 seeds. | This lesson's model (illustrative) |
| × 10 runs, ÷ √10 scatter | Ten times the runs cut the P90's scatter from ± $4.7M to ± $1.3M, close to the square-root rule. | This lesson's model; K5 |
| 0.1³ = 1 in 1,000 | The chance, under these inputs, that the margin, capital and discount rate all land in the top tenth of their ranges: near the high-cost corner. 2 of the 1,000 runs did. | This lesson's model |
| ρ = 0.86 | The margin's rank correlation with the developer's cost, within the assumed ranges. | This lesson's model |
Next
Where this came up in research
A present-value framework turns the delayed computing capacity into the grid MW it needs and prices the delay in three ledgers.
Inputs are screened with Latin hypercube sampling.
The delay is treated as exogenous and parameters are illustrative; network feasibility is not modeled, and the social perspective is illustrated with a single bridge-power example.
The whole case, with its accounts and a toy of its own: CF7, the cost of waiting. This page's toy borrows CF7's load. Illustrative round numbers, not the study's inputs, equations or results.
Sources and further reading
- McKay, M. D., Beckman, R. J., and Conover, W. J. (1979). A Comparison of Three Methods for Selecting Values of Input Variables in the Analysis of Output from a Computer Code. Technometrics, 21(2), 239–245. The Latin hypercube.
- Saltelli, A., Ratto, M., Andres, T., Campolongo, F., Cariboni, J., Gatelli, D., Saisana, M., and Tarantola, S. (2008). Global Sensitivity Analysis: The Primer. Wiley.
- Saltelli, A., Annoni, P., Azzini, I., Campolongo, F., Ratto, M., and Tarantola, S. (2010). Variance based sensitivity analysis of model output. Design and estimator for the total sensitivity index. Computer Physics Communications, 181(2), 259–270. The lab's variance shares.
- Iman, R. L., and Conover, W. J. (1982). A distribution-free approach to inducing rank correlation among input variables. Communications in Statistics – Simulation and Computation, 11(3), 311–334. The lab's practice task 3.
- Li et al. (2026). Accepted paper on the cost of delayed grid energization for large loads, 2026 North American Power Symposium (NAPS), presented October 2026; DOI pending.
- code-delayed-energization on GitHub, version 1.0.2 (2 November 2026).
Spotted an error, or stuck? Write to hlli@ksu.edu. Corrections are made in place and dated here.
Text licensed CC BY 4.0, code MIT: teachers and students may reuse and adapt it, with credit to Honglin Li.