Propagation of Uncertainty, Correlation and Monte Carlo
The law of propagation in the previous lesson rests on two assumptions that are easy to forget: the inputs are independent, and the model is close to linear over the range of each input's uncertainty. A ratio of two readings from the same meter breaks the first, a magnitude of a noisy small vector breaks the second. This lesson adds the covariance term for the first case and the Monte Carlo method of GUM Supplement 1 (JCGM 101:2008) for the second, and uses Monte Carlo as a check on any budget.
The general law of propagation
For , a first-order Taylor expansion gives
where is the correlation coefficient between the two estimates. Correlation appears whenever two inputs share an error source: the same meter's gain, the same reference voltage, the same temperature, the same calibration standard.
For a ratio the relative form is compact:
With and equal relative uncertainties the ratio is exact: a shared gain error cancels. That is why ratio measurements (bridges, ratiometric ADCs, divider ratios read with one meter) are so accurate. In a difference of two readings from one meter, a shared offset cancels while a shared gain error survives in proportion to ; in a sum, a shared offset doubles instead of growing by . Write the model and let the algebra decide.
Worked example: a divider ratio read with one DMM
Given: and read on the same range of one DMM whose gain error is within (common to both readings) and whose other errors (noise, linearity) are within independently for each reading; both rectangular.
Find: for , with and without the correlation.
Solve: each reading has and , so , and the correlation coefficient is .
Check: with the correlation only the independent part survives, , which a Monte Carlo run that draws one shared gain error per trial confirms:
import numpy as np
# Divider ratio r = V2 / V1, both read with the same DMM on the same range.
V1, V2 = 10.0000, 3.3330 # volts
g_lim = 50e-6 # shared gain error limit (relative), rectangular
n_lim = 20e-6 # independent noise/linearity limit per reading (relative), rectangular
u_g, u_n = g_lim / np.sqrt(3), n_lim / np.sqrt(3)
r = V2 / V1
# Each reading's relative uncertainty is sqrt(u_g^2 + u_n^2); the gain part is fully correlated.
u_rel = np.hypot(u_g, u_n)
uncorr = r * np.sqrt(2) * u_rel # pretending the readings are independent
rho = u_g**2 / u_rel**2 # correlation coefficient of the two readings
corr = r * np.sqrt(2 * u_rel**2 - 2 * rho * u_rel**2) # with the covariance term
print(f"r = {r:.5f}; correlation coefficient of the readings = {rho:.2f}")
print(f"u(r) ignoring correlation: {1e6 * uncorr / r:5.1f} ppm")
print(f"u(r) with correlation: {1e6 * corr / r:5.1f} ppm")
rng = np.random.default_rng(11)
N = 1_000_000
g = rng.uniform(-g_lim, g_lim, N) # one gain error shared by both readings
m1 = V1 * (1 + g + rng.uniform(-n_lim, n_lim, N))
m2 = V2 * (1 + g + rng.uniform(-n_lim, n_lim, N))
r_mc = m2 / m1
print(f"Monte Carlo: {1e6 * r_mc.std() / r:5.1f} ppm")r = 0.33330; correlation coefficient of the readings = 0.86
u(r) ignoring correlation: 44.0 ppm
u(r) with correlation: 16.3 ppm
Monte Carlo: 16.3 ppm
When first order fails
The law of propagation linearises around the estimates. That fails when curves strongly within of an input, or when a sensitivity coefficient is zero at the estimate. A lock-in amplifier measuring a weak signal reports the magnitude of two noisy quadrature components. With , the coefficient is zero, so first order says the noise on does not matter, and it predicts a symmetric interval that reaches almost down to zero. In reality noise on can only increase : the distribution is skewed (a Rice distribution) and its mean is biased upward.
Monte Carlo propagation (GUM Supplement 1)
- Assign a probability distribution to every input (the same ones as in the budget: normal, rectangular, ...), with correlations if any.
- Draw samples of all inputs, typically .
- Evaluate the model for each sample.
- Report the mean (or the model value) and the standard deviation of the outputs, and a coverage interval from the percentiles (probabilistically symmetric: and ) or the shortest interval containing .
No derivatives, no linearity assumption, and correlations are handled by drawing shared errors once per trial. The price is computing time, negligible for any model an engineer writes by hand.
import numpy as np
# Magnitude of a small signal from two quadrature components (a lock-in amplifier), microvolts.
X, uX = 0.0, 1.0
Y, uY = 2.0, 1.0
A = np.hypot(X, Y)
# first-order (GUM law of propagation): c_X = X/A = 0, c_Y = Y/A = 1
u_lin = np.hypot(X / A * uX, Y / A * uY)
print(f"first order: A = {A:.3f} uV, u(A) = {u_lin:.3f} uV, 95 % interval [{A - 1.96 * u_lin:.2f}, {A + 1.96 * u_lin:.2f}] uV")
rng = np.random.default_rng(5)
N = 1_000_000
A_mc = np.hypot(rng.normal(X, uX, N), rng.normal(Y, uY, N))
lo, hi = np.percentile(A_mc, [2.5, 97.5])
print(f"Monte Carlo: mean A = {A_mc.mean():.3f} uV, u(A) = {A_mc.std():.3f} uV, "
f"95 % interval [{lo:.2f}, {hi:.2f}] uV")
# shortest 95 % interval
s = np.sort(A_mc)
k = int(0.95 * N)
i = int(np.argmin(s[k:] - s[:N - k]))
print(f"shortest 95 % interval [{s[i]:.2f}, {s[i + k]:.2f}] uV")
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(6, 3))
ax.hist(A_mc, bins=200, range=(0, 6), density=True, color="tab:blue", alpha=0.7, label="Monte Carlo")
xs = np.linspace(0, 6, 300)
ax.plot(xs, np.exp(-0.5 * ((xs - A) / u_lin) ** 2) / (u_lin * np.sqrt(2 * np.pi)), "k--", label="first-order normal")
ax.set_xlabel("amplitude A (uV)")
ax.set_ylabel("density")
ax.legend()
fig.tight_layout()
plt.show()first order: A = 2.000 uV, u(A) = 1.000 uV, 95 % interval [0.04, 3.96] uV
Monte Carlo: mean A = 2.273 uV, u(A) = 0.913 uV, 95 % interval [0.59, 4.13] uV
shortest 95 % interval [0.49, 4.01] uV
The Monte Carlo interval is shifted and asymmetric: the true signal is very unlikely to be below , and the mean output () is biased above the estimate (). The first-order interval is wrong at both ends. In practice, signal magnitudes near the noise floor (lock-in, spectrum analysers, RMS of noise) all behave like this (Spectrum Analysers).
Guided lab: check a budget by Monte Carlo
Hand calculation. Take the budget of the shunt example: of from first-order propagation.
Simulation. Write a Monte Carlo version: draw (normal for the Type A part, rectangular for the spec), (normal, ), (rectangular ) and (rectangular ), evaluate the model and compare the standard deviation with . The model is nearly linear, so expect agreement within a few ppm; a disagreement means a mistake in a sensitivity coefficient.
What you would measure. For the divider ratio: measure and of a divider with one 6½-digit DMM, then with two different DMMs. The one-meter ratio should repeat to a few ppm across days; the two-meter ratio drifts by the meters' relative gain errors (tens of ppm). This is the experimental face of the correlation term.
Hazards and safe setup. Low-voltage divider from a current-limited supply; nothing else.
Pitfalls
- Ignoring correlation in a ratio (overestimates) or in a sum of readings from one meter (underestimates).
- Using first-order propagation near a zero sensitivity coefficient or near a physical bound (a magnitude, a resistance near zero).
- Running Monte Carlo with too few trials: the percentile needs about trials or more to be stable to two digits.
- Forgetting to fix the random seed in a report: results should be reproducible.
Practice
- Two readings with each and : what is for their ratio, and for their product?
- Why is a Wheatstone bridge insensitive to the exact value of its supply voltage?
Answer
- Ratio: . Product: (fully correlated terms add linearly).
- At balance the condition is a ratio of resistances; the supply multiplies both arms equally, a perfectly correlated factor that cancels (DC Bridges).
Test yourself
Two readings share the same gain error. In their ratio this error
- doubles
- adds in quadrature
- cancels
- becomes random
First-order propagation is unreliable when
- the model is a product of powers
- a sensitivity coefficient is zero at the estimate or the model curves strongly within the uncertainty
- the inputs are normal
- there are more than three inputs
GUM Supplement 1 gives a coverage interval from
- always
- percentiles of the simulated output distribution
- the largest input uncertainty
- the Welch-Satterthwaite formula
The mean of with noisy and is
- exactly the noise-free magnitude
- biased upward
- biased downward
- zero