Monte Carlo Uncertainty Propagation
Sample the uncertain inputs many times, run the code on each, and build the output distribution directly; general but expensive.
Propagation by Sampling
The most general way to propagate uncertainty through a code is to sample. Draw many sets of inputs from their probability distributions, run the code once for each set, and collect the outputs. The resulting collection of outputs is a sample of the output distribution, from which any statistic can be estimated: mean, spread, percentiles, and the probability of exceeding a threshold.
Why It Is General
Monte Carlo makes no assumptions about the model. It works for nonlinear codes, discontinuous responses, and arbitrary input distributions, because it only ever calls the code as a black box. This generality is its great strength: where analytic propagation and linearized methods break down, sampling still works.
import numpy as np
rng = np.random.default_rng(1)
N = 20000
a = rng.normal(1.0, 0.1, N)
b = rng.uniform(2.0, 3.0, N)
y = a*np.exp(-b) # stand-in for an expensive code call
print('mean', y.mean(), 'std', y.std())
print('P(y>0.15)', np.mean(y > 0.15))
The Cost
The catch is the number of runs. The statistical error of a Monte Carlo estimate falls only as one over the square root of the sample size, so halving the error requires four times as many runs. For a code where a single run is expensive, thousands of runs may be infeasible. This drives the use of variance-reduction techniques, quasi-random sampling, and surrogate models that stand in for the expensive code.
Convergence of the Estimate
Monte Carlo results themselves need a convergence check: the estimated statistic should stabilize as the sample grows, and its own uncertainty should be reported. A mean quoted from a Monte Carlo study without its statistical error is incomplete, because a different random seed would give a slightly different value. Reporting the sample size and the estimator's uncertainty lets a reader judge whether the study was run long enough.
Monte Carlo is the reference method against which cheaper propagation techniques are checked, the honest baseline when accuracy matters more than speed.