Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

12. Covariance and the limits of linearisation

School of Engineering, Nazarbayev University

Track: advanced  ·  Prerequisites: Chapters 3, 4 and 11, matrix notation

Reading: Taylor, ch. 3.11 and 9 · Bevington & Robinson, ch. 3.2 · Fornasini, ch. 8.4 · GUM, clause 5.2 · JCGM 101:2008

The propagation law of Chapter 3, uy2=∑i(∂f/∂xi)2ui2u_y^2 = \sum_i (\partial f/\partial x_i)^2 u_i^2, rests on two assumptions: the inputs are independent, and the model is linear over the range of the input errors. Research problems violate both routinely. Fit parameters are correlated with each other, two readings of one instrument share its calibration error, and quantities such as ratios, exponentials and inverse powers are strongly nonlinear once relative uncertainties reach ten per cent or so.

This notebook

  1. generalises the propagation law to correlated inputs and to several outputs;

  2. shows that intermediate results must carry their covariance;

  3. derives the second-order correction and uses it to judge when the linear law can be trusted;

  4. presents Monte Carlo propagation, the method that needs neither assumption.

12.1 The general law of propagation

Consider mm output quantities yk=fk(x1,…,xn)y_k = f_k(x_1, \dots, x_n). Collect the small errors of the inputs in a vector δx\delta\boldsymbol{x} and those of the outputs in δy\delta\boldsymbol{y}. To first order,

δyk=∑i=1nJki δxi,Jki=∂fk∂xi,\delta y_k = \sum_{i=1}^{n} J_{ki}\,\delta x_i , \qquad J_{ki} = \frac{\partial f_k}{\partial x_i} ,

where J\mathsf{J} is the Jacobian (sensitivity) matrix. The statistical information about the inputs is contained in the covariance matrix

(Cx)ij=⟨δxi δxj⟩,(\mathsf{C}_x)_{ij} = \langle \delta x_i\,\delta x_j \rangle ,

whose diagonal elements are the variances ui2u_i^2 and whose off-diagonal elements are the covariances uij=ρijuiuju_{ij} = \rho_{ij}u_iu_j, with −1≤ρij≤1-1 \le \rho_{ij} \le 1 the correlation coefficient. The same average for the outputs gives

(Cy)kl=⟨δyk δyl⟩=∑i,jJki ⟨δxi δxj⟩ Jlj,(\mathsf{C}_y)_{kl} = \langle \delta y_k\,\delta y_l\rangle = \sum_{i,j} J_{ki}\,\langle \delta x_i\,\delta x_j\rangle\,J_{lj} ,

that is,

Cy=J Cx JT.\mathsf{C}_y = \mathsf{J}\,\mathsf{C}_x\,\mathsf{J}^{\mathsf T} .

This single matrix equation is the whole first-order theory. For one output it reads

uy2=∑ici2ui2+2∑i<jcicj ρij uiuj,ci=∂f∂xi,u_y^2 = \sum_i c_i^2 u_i^2 + 2\sum_{i<j} c_i c_j\,\rho_{ij}\,u_i u_j , \qquad c_i = \frac{\partial f}{\partial x_i} ,

and the second sum is what Chapter 3 left out. It can have either sign: correlation can increase the output uncertainty or reduce it, and can even cancel it.

Sum and difference of two correlated quantities

For y±=x1±x2y_\pm = x_1 \pm x_2 with equal uncertainties uu,

uy±2=2u2(1±ρ).u_{y_\pm}^2 = 2u^2(1 \pm \rho) .

With ρ=+1\rho = +1 the difference has no uncertainty at all, and the sum has twice that of one term (the errors add linearly, not in quadrature). This is the principle behind every differential measurement: if two readings share a common error, their difference is free of it. Two temperatures read with the same thermometer share its calibration offset, so a temperature difference is known better than either temperature. Two total energies computed with the same functional and settings share most of their systematic error, which is why energy differences are far more reliable than absolute energies.

  rho    u(a - b)   u(a + b)
 -1.0    0.2000     0.0000
 -0.5    0.1732     0.1000
 +0.0    0.1414     0.1414
 +0.5    0.1000     0.1732
 +0.9    0.0447     0.1949
 +1.0    0.0000     0.2000

Where does a correlation coefficient come from?

A common situation: two readings x1x_1 and x2x_2 each have an independent random error with standard deviation ss and share a systematic error (calibration) with standard uncertainty bb. Then δxi=εi+β\delta x_i = \varepsilon_i + \beta with a common β\beta, and

u12=u22=s2+b2,u12=⟨(ε1+β)(ε2+β)⟩=b2,ρ=b2s2+b2.u_1^2 = u_2^2 = s^2 + b^2 , \qquad u_{12} = \langle(\varepsilon_1 + \beta)(\varepsilon_2 + \beta)\rangle = b^2 , \qquad \rho = \frac{b^2}{s^2 + b^2} .

The covariance is simply the variance of the shared part. For the difference, u2=2(s2+b2)−2b2=2s2u^2 = 2(s^2+b^2) - 2b^2 = 2s^2: the calibration uncertainty has dropped out, as it must.

12.2 Intermediate results must carry their covariance

Long calculations are done in stages, and the outputs of one stage are the inputs of the next. Even if the original inputs are independent, the intermediate quantities are generally not, because they were computed from the same numbers.

A minimal example: from independent a±uaa \pm u_a and b±ubb \pm u_b form s=a+bs = a + b and d=a−bd = a - b, and then p=s d=a2−b2p = s\,d = a^2 - b^2. The Jacobian of the first stage is J=(111−1)\mathsf J = \begin{pmatrix}1 & 1\\ 1 & -1\end{pmatrix}, so

Csd=J(ua200ub2)JT=(ua2+ub2ua2−ub2ua2−ub2ua2+ub2).\mathsf C_{sd} = \mathsf J \begin{pmatrix}u_a^2 & 0\\ 0 & u_b^2\end{pmatrix} \mathsf J^{\mathsf T} = \begin{pmatrix} u_a^2 + u_b^2 & u_a^2 - u_b^2 \\ u_a^2 - u_b^2 & u_a^2 + u_b^2 \end{pmatrix} .

Unless ua=ubu_a = u_b, the sum and the difference are correlated.

covariance matrix of (s, d):
[[0.0425 0.0375]
 [0.0375 0.0425]]
correlation coefficient: +0.882

u(p), direct                    : 2.0224
u(p), two stages with covariance: 2.0224
u(p), two stages, cov. ignored  : 1.7000   <- wrong

Carried through with its covariance, the staged calculation reproduces the direct one exactly. Without it, the answer is too small by 16 % here, and it can be wrong by orders of magnitude when the correlation is strong (the Arrhenius example Chapter 22 is such a case). The practical rules are:

  • propagate from the original, independent inputs in one step whenever possible;

  • when intermediate results are published or passed on, give their covariance matrix, not only their standard uncertainties.

12.3 Beyond first order

The linear law keeps only the tangent to ff. To see what is neglected, carry the expansion one order further. For one input with error δx\delta x of zero mean and variance u2u^2,

y=f(x)+f′ δx+12f′′ δx2+…y = f(x) + f'\,\delta x + \tfrac12 f''\,\delta x^2 + \dots

A shift of the mean. Averaging,

⟨y⟩=f(x)+12f′′(x) u2+…\langle y\rangle = f(x) + \tfrac12 f''(x)\,u^2 + \dots

The mean of the output is not the function of the mean input. A curved function converts symmetric scatter of xx into a bias of yy. For several inputs the correction is 12∑ijHij(Cx)ij\tfrac12\sum_{ij} H_{ij}(\mathsf C_x)_{ij} with Hij=∂2f/∂xi∂xjH_{ij} = \partial^2 f/\partial x_i\partial x_j the Hessian.

A correction to the variance. For a normally distributed δx\delta x (so that ⟨δx3⟩=0\langle\delta x^3\rangle = 0 and ⟨δx4⟩=3u4\langle\delta x^4\rangle = 3u^4),

var⁡(y)=f′2u2+12f′′2u4+…\operatorname{var}(y) = f'^2u^2 + \tfrac12 f''^2u^4 + \dots

A criterion. Comparing the two terms of the variance, the linear law is adequate when

∣f′′(x) uf′(x)∣≪1,\left|\frac{f''(x)\,u}{f'(x)}\right| \ll 1 ,

in words: when the slope of ff changes little over a distance uu. For a power law f=xnf = x^n the left-hand side is ∣n−1∣ u/x|n-1|\,u/x, so the criterion is a statement about the relative uncertainty. At a relative uncertainty of 1 % the linear law is excellent for any reasonable exponent; at 30 % it is not, as we shall see.

Three instructive cases:

ModelLinear lawWhat actually happens
y=exy = e^{x}, x∼N(μ,σ2)x \sim N(\mu, \sigma^2)y=eμy = e^\mu, uy=eμσu_y = e^\mu\sigmalog-normal: mean eμ+σ2/2e^{\mu + \sigma^2/2}, skewed to the right
y=x2y = x^2 at x=0±σx = 0 \pm \sigmauy=0u_y = 0⟨y⟩=σ2\langle y\rangle = \sigma^2, standard deviation 2 σ2\sqrt2\,\sigma^2
y=a/by = a/b with ub/b=0.3u_b/b = 0.3symmetric normalheavy tails; mean and variance do not exist

The second case is the extreme one: at a stationary point the first derivative vanishes and the linear law returns zero, which is plainly wrong. It occurs in practice whenever a quantity is measured near an optimum, or when a squared amplitude is estimated from a noisy signal that is consistent with zero.

12.4 Monte Carlo propagation

The general solution is to give up the expansion altogether and propagate the distributions instead of their widths. The recipe (GUM Supplement 1) is short:

  1. assign a probability distribution to every input (normal, rectangular, or a joint normal with a covariance matrix);

  2. draw MM random sets of inputs;

  3. evaluate the model for each set;

  4. summarise the MM outputs: mean or median, standard deviation, and a probability interval from the percentiles.

No derivatives are needed, nonlinearity and correlation are handled automatically, and the output distribution is obtained in full, including its asymmetry. The cost is MM evaluations of the model. The statistical error of the result is easy to state: the standard deviation obtained from MM samples has a relative uncertainty of about 1/2M1/\sqrt{2M} (Section 4.3), so M=105M = 10^5 fixes it to 0.2 %, which is more than enough for any uncertainty statement.

The figure compares the linear law with Monte Carlo for the cases above.

<Figure size 1012x792 with 4 Axes>
y = exp(x), x = 0 +/- 0.5
  linear law : 1.000 +/- 0.500
  Monte Carlo: mean 1.133 (exact 1.133), median 0.999, 68 % interval [0.607, 1.648]
  second-order estimate of the mean: 1.125

y = a / b, b = 1.0 +/- 0.3
  linear law : 1.000 +/- 0.304
  Monte Carlo: median 0.999, 68 % interval [0.764, 1.430],  sample std 6.4 (meaningless)
  fraction of samples outside y0 +/- 3 u0: 0.0562  (normal: 0.0027)

Panel (a) is the formula u2=2ux2(1±ρ)u^2 = 2u_x^2(1\pm\rho) of Section 12.1.

Panel (b). The output is log-normal. Its mean (blue dashed line) lies 13 % above eμe^\mu (red dashed line), as the second-order formula predicts to within a per cent, and the distribution is skewed. The honest summary is an asymmetric interval. Equivalently, one reports ln⁡y\ln y, which is normal: ln⁡y=0.0±0.5\ln y = 0.0 \pm 0.5, or “y=1.0y = 1.0 within a factor of e0.5=1.65e^{0.5} = 1.65”. Quantities that are positive and uncertain by a large factor (rate constants, pre-exponential factors, permeabilities, concentrations spanning decades) are best treated on a logarithmic scale from the start.

Panel (c). Dividing by a quantity with 30 % uncertainty produces a long tail towards large values, because bb can come close to zero. The sample standard deviation printed above is not a property of the distribution, which has no finite variance; it only reflects the largest outliers that happened to be drawn. The median and the percentile interval remain well defined, and they are what should be reported.

Panel (d) shows the breakdown quantitatively for y=1/xy = 1/x with x=1±qx = 1 \pm q. Because 1/x1/x is monotonic, percentiles of xx map onto percentiles of yy, and the 68 % interval is [1/(1+q), 1/(1−q)][1/(1+q),\ 1/(1-q)] (lines; the symbols are Monte Carlo). Its half-width exceeds the linear uy=qu_y = q by the factor 1/(1−q2)1/(1-q^2), which stays close to one. The asymmetry is another matter: the upper half of the interval is longer than the lower half by the factor (1+q)/(1−q)(1+q)/(1-q), which is 1.11 at q=5 %q = 5\,\%, 1.22 at 10 % and 1.86 at 30 %. The linear law gets the width roughly right long after it has stopped describing the shape.

12.5 Practical guidance

  • Write the model as one function of the original, independently measured inputs and propagate in one step.

  • If inputs share an error source, either model the shared source as an explicit input, or include the covariance.

  • Check ∣f′′u/f′∣|f''u/f'|, or simply compare the linear result with a Monte Carlo run. The comparison takes three lines with ep.monte_carlo and removes the need to argue.

  • When the output distribution is skewed, report the median with a percentile interval, or work with the logarithm.

  • Never propagate through a ratio whose denominator is compatible with zero. Reformulate the question.

Exercises

  1. Two masses are weighed on the same balance, which has a calibration uncertainty of 0.03 g (common to both) and a repeatability of 0.01 g. Find the uncertainty of their sum and of their difference.

  2. Derive the variance correction 12f′′2u4\tfrac12 f''^2u^4 of Section 12.3 and verify it by Monte Carlo for f=x2f = x^2 at x=1x = 1, u=0.3u = 0.3.

  3. A relative humidity is obtained from the ratio of two vapour pressures that are both computed from temperatures read on the same thermometer. Without calculation, argue whether the thermometer’s calibration error matters more or less than its random error.

  4. For the ratio in panel (c), replace the normal distribution of bb by a rectangular one with the same standard deviation (dist=["normal", "uniform"]). Does the output now have a finite variance? Why?