Professional Documents
Culture Documents
This article has been downloaded from IOPscience. Please scroll down to see the full text article.
(http://iopscience.iop.org/0026-1394/48/3/L03)
View the table of contents for this issue, or go to the journal homepage for more
Download details:
IP Address: 148.204.24.56
The article was downloaded on 06/04/2011 at 15:29
SHORT COMMUNICATION
Abstract
Compact expressions for the GUM’s ‘law of propagation of uncertainty’ and its extensions,
including the possible effects of corrections for non-linearity and including the effects of
correlation in the variables, are obtained in terms of simple manipulations on three basic
tensors: the gradient, the Hessian and the third order third derivative tensor of the measurement
function. These formulae are an alternative to those involving mixed matrix and differential
algebra. They provide a systematic and reproducible way to arrange the terms provided by the
derivatives of various orders of a measurement function. The proposed formulae, which appear
mathematically complicated, are surprisingly easy to implement in spreadsheet programs and
interpreted matrix oriented programming languages. This is illustrated by means of an
example of the propagation of uncertainty for the ratio of two normal and correlated variables.
0026-1394/11/030022+07$33.00 © 2011 BIPM & IOP Publishing Ltd Printed in the UK & the USA L22
Short Communication
uncertainty’ (5.1.2 in [2]), is as follows for uncorrelated Equation (3) can be seen as a compact form of the law
variables, taking into account corrections of order higher than of propagation and is useful to take into account the non-
one in the Taylor expansion of the model f : linearity of a model, or to test a model for the accuracy of
n the linear approximation, in the evaluation of the standard
∂f 2 2 uncertainty as explained in [1]. However, it is worth noting
u2c (y) u (xi )
i=1
∂xi that in equations (1), (2) and (3), the input variables should be
2 normally distributed. The same hypothesis applies throughout
n n
1 ∂ 2f this article.
+
2 ∂xi ∂xj Equations (1), (2) and (3) all contain sums over symbols
i=1 j =1
representing values of derivatives of f . The number of
∂f ∂ 3f terms and the complexity of their combinations in these sums
+ u2 (xi )u2 (xj ), (1) increase with the number of variables in the model. For
∂xi ∂xi ∂ 2 xj
example, for a model f which depends on three correlated
where ∂f /∂xi is ∂f /∂Xi evaluated at x. variables, the full expression (3) generates 131 terms in total.
For correlated variables, taking into account only a first Some of them are repeated so that they combine to form 78
order Taylor approximation of f , the equation for the combined different terms which must be summed to obtain the combined
variance is given by variance. In practice, some of the generated terms are usually
n zero; however, a substantial number of them can remain.
∂f 2 2
uc (y)
2
u (xi ) Another example is the case of the model for the determination
i=1
∂xi of the density of wet air [4], with four random variables:
n−1 n the temperature, the pressure, the relative humidity and the
∂f ∂f
+2 u(xi ) u(xj ) ρij model fitting error, where the propagation formula involves 34
i=1 j =i+1
∂xi ∂xj derivatives in total which combine into 22 different terms to
+ ···. (2) sum to obtain the combined variance.
The evaluation of the non-linear effects, i.e. the two last
The GUM does not provide an expression for the case terms on the right-hand side of equation (3), requires a great
where the variables are correlated and contributions of order deal of work in general. This effort is sometimes only required
higher than one in the approximation of f are taken into to check the accuracy of the linear approximation of the model.
account simultaneously. The case of the propagation of The last term of equation (3), which contains the Jacobian of
the uncertainty in a model such as f when the linearized a trace, implies that manipulations of symbolic matrices need
approximation is not adequate is considered in [3] and requires to be performed first, then a subsequent symbolic derivation
the implementation of Monte Carlo methods. However, of the result is done and, finally, the numerical evaluation
another expression for the combined variance was recently and numerical matrix products are performed. Symbolic
derived by Mana and Pennecchi in [1], who propose a version algebra and numerical evaluations are not separated in this
of the law of propagation for non-linear models that takes into formulation and this represents a serious difficulty in its
account approximations up to the third order in the Taylor practical implementation for complex models.
expansion of the model. It is worth mentioning that the The available mathematical programs of symbolic algebra
formulation in [1] encompasses the cases of both equations (1) can easily display symbolic or numerically evaluated gradients,
and (2). The formulation for the variance σy2 from [1] is Hessian matrices and any subset of the third order third
transcribed here: derivative tensor of the model that are involved in the
above mentioned formulae. These programs make the
u2c (y) ≡ σy2 = J0 Cx J0 + 21 tr[(H0 Cx )2 ]
numerically evaluated matrices available to anyone who wants,
+ J0 Cx [∂x tr(HCx )]0 , (3) or needs, to use spreadsheets or matrix oriented languages
to implement uncertainty propagation formulae for some
where J0 is the Jacobian of f , namely its gradient, evaluated at application. On the one hand, the spreadsheets are widely used
the mean value of the vector of random variables or, in practice, to perform statistical analysis and uncertainty propagation and
at the measured x. The Hessian matrix H is also evaluated at do not provide a systematic way to perform the summations
the measured input variables x. The evaluated Hessian matrix efficiently, and actually without risks of manipulation error.
is denoted by H0 . The matrix Cx is the covariance matrix of the It should therefore be useful to avoid the mixing of matrix
set of input variables. The gradient operator, ∂x in equation (3), operations and symbolic derivations in the propagation formula
provides the Jacobian of the trace which is its argument and and to allow the use of simple numerical matrices and products
this Jacobian is again evaluated at the measured x, as denoted between them in a spreadsheet. The evaluation of the necessary
by the subscript 0. This notation will be used, for matrices derivatives may be performed by another program. On the
and for the gradient vector, throughout this article in order to other hand, it is noticeable that matrix oriented languages are
distinguish between the quantities and their associated values. nowadays able to perform most of the necessary symbolic and
A bold face upper-case letter with the subscript 0 refers to a numerical calculations used in the uncertainty propagation but
matrix evaluated at x. The vectors are denoted with bold face a formula that fully uses the matrix language is not available.
upper-case letters when referring to quantities and with bold We therefore propose to set a matrix expression for
face lower-case letters when referring to their values. the propagation of uncertainty which uses simple products
t3,corr = w • s, (6) It is now interesting to derive, from the previous general result,
another one for the particular case where the variables are
where w can be calculated by means of Hadamard (element- uncorrelated, i.e. where Rx = In and In is the identity matrix
wise or Schur) products [6] denoted by as follows: let u in n dimensions. This should allow us to recover the formula
be the vector of combined uncertainties in x so that u = given by equation (1) but provide a very compact tensor algebra
(u(x1 ), · · · , u(xn )), and Rx , the correlation matrix of x with version of it. In this particular case ρij = δij , where δij is
components ρj i . the Kronecker symbol. We denote by ti,unc the ith term of
w = [(∇f0 u) Rx ] u . (7) the left-hand side of equation (3) in the case of uncorrelated
variables. Thus, we can write u2c (y) t1,unc + t2,unc + t3,unc
By introducing the matrix P k,0 as shown in figure 1, the where t1,unc ≡ t1,corr . The only difference between t1,unc and
vector s in equation (6) has its kth component written as t1,corr is that in t1,unc , the matrix Cx is a diagonal matrix.
Equation (4) can be reduced to a Hadamard product since Cx =
sk = u P k,0 Rx u, (8) (δij u(xi )u(xj )) = In u where u = (u2 (x1 ), · · · u2 (xn )). So
the result multiplied again by vec(Cx ) provides the expected implemented. The Kronecker product is available through the
result t2,corr = 7.24×10−8 . function kron(). There are various ways to stack elements
To calculate the term t3,corr requires a little more effort. into vectors or to vectorize matrices. The solutions, which are
Figure 5 shows a possible arrangement of the necessary employed here, are compatible between the three mentioned
matrices. In the upper part of the figure, each component programs. The following verbatim code applies to any of
sk of vector s is calculated. In the lower part of the figure them. The Matlab [9] (:) operator stands for vec(), and the
w is calculated from equation (7). The components of s are [-;-] structure is used for vertical stacking. The corresponding
stacked in a column vector and the scalar product between code is shown below:
w and s is calculated to obtain t3,corr by means of a matrix
product. The required operations are simple products obtained 01 % User Provided Matrices
02 format long
through mmult() and Hadamard (element-wise) products. In 03 x=[0;1];
the present case the result is t3,corr = 2.096×10−7 . It is worth 04 u=[0.02;0.01];
noting that t3,corr > t2,corr ; the major contribution from non- 05 Rx=[1,0.9;0.9,1];
linear effects in the model to the variance comes from t3,corr 06 Gr0=[1;0];
in this case. It shows that it is worthwhile to calculate all the 07 H0=[0,-1;-1,0];
08 P10=[0,0;0,2];
terms since it cannot be determined a priori which terms might 09 P20=[0,2;2,0];
or might not be negligible. 10
11 % Calculation of Variance
4.2. Matrix language implementation 12 Cx=u*u’.*Rx;
13 T1CORR=Gr0’*Cx*Gr0
The implementation of the proposed formulae within the 14 T2CORR=1/2*Cx(:)’*kron(H0,H0)*Cx(:)
15 s=[u’*(P10.*Rx)*u ; u’*(P20.*Rx)*u];
framework of matrix oriented interpreted languages such as
16 T3CORR=((Gr0.*u)’*Rx).*u’*s
Matlab [9], Octave [10] or Scilab [11] is quite simple. Each 17
language contains the standard matrix and Hadamard products 18 % Results
Figure 5. x1 /x2 problem setup for t3,corr in a spreadsheet. is the Hadamard (element-wise) product, • is the standard matrix product given
by mmult(). q1 and q2 are intermediate vectors of numerical values.
19 uc=sqrt(T1CORR+T2CORR+T3CORR)
line 07) and P k,0 (coded as P10 and P20, lines 08, 09), are then
20
21 % RESULTS obtained by means of an evaluation instruction ev().
22 % T1CORR = 4.000e-04 Line 12 builds the covariance matrix Cx from the
23 % T2CORR = 7.240e-08 correlation matrix Rx and the combined uncertainty vector
24 % T3CORR = 2.096e-07 u. It can be noted how the proposed formulae are coded in a
25 % Expected result
26 % uc = 2.0007048e-2
compact and straightforward manner from line 13 to line 16,
27 % End of Code giving the expected results. The Hadamard product of two
matrices is coded as (.*) while the matrix product is coded as
The matrices supplied by the user are entered from line (*). The vertical stacking of s is obtained on line 15. The
03 to line 09. The first two vectors contain, respectively, the results were obtained in Octave [10]. This code was checked
measurements and their standard uncertainties. These vectors for compatibility and runs in Matlab [9] and Scilab [11] without
and the correlation matrix (line 05) are obtained from statistical any change.
analysis. The matrices in lines 06 to 09 were obtained
from Maxima [12], a symbolic algebra program. A program
such as Maxima provides some specialized modules of linear 5. Conclusion
algebra where the jacobian() (transpose of the gradient) and
We have developed an alternative way to write the GUM
the hessian() functions are defined and can be used to obtain
formula or the formulation of Mana and Pennecchi for the
∇f and H . The blocks P k of the third order third derivative propagation of uncertainty. The sums involved in equation (3)
tensor, for example, can be obtained from nested ‘for’ loops can be obtained through standard matrix products. This allows
on the differential operator as shown in the following lines: us to handle the propagation formula from within a spreadsheet
for i : 1 thru 2 do or any matrix oriented program even for models with many
for j : 1 thru 2 do variables. The proposed formulae are suitable to be used
P2[i,j]:= diff(f(X1,X2),L[i],1, in spreadsheet programs and for programming within matrix
L[j],1,L[2],1); oriented interpreted languages. The implementation of the
Kronecker product as a user function in spreadsheets would be
In this code we build P 2 from its components very useful.
∂ 3 f/(∂Xi ∂Xj ∂X2 ) by differentiating the model f with respect The gradient vector, the Hessian and the third order
to each of the quantities in a list L that contains Xi , for i =1, derivative tensor of the model evaluated at a given set of
2. The values ∇f0 (coded as Gr0, line 06), H0 (coded as H0, estimates of the variables are required and can be obtained