You are on page 1of 5

Proceedings of ENCIT 2008

c 2008 by ABCM
Copyright

12th Brazilian Congress of Thermal Engineering and Sciences


November 10-14, 2008, Belo Horizonte, MG

Uncertainty Calculus in Metrology


Valter Y. Aibe
Mikhail D. Mikhailov
INMETRO, Fluid Dynamic Metrology Division
Av. Nossa Senhora das Graas, 50 Duque de Caxias - RJ CEP 25250-020

vyaibe@inmetro.gov.br
lamev@inmetro.gov.br
Abstract. A new uncertainty calculus is introduced and implemented in Mathematica software system. Similarly to
the complex and interval numbers, a new object x x called uncertainty number is introduced. The uncertainty
calculus transforms a functional relationship of uncertainty numbers f [x1 x1 , x2 x2 , ..., xn xn ] into an
uncertainty number y y, assuming that all input quantities xi xi are independent. Examples demonstrating
the uncertainty calculus are given. The new dynamic interactive computing, introduced by Wolfram Research with the
release of Mathematica 6 is also demonstrated. The result presented in this paper were generated from Mathematica 6
notebook.
Keywords: uncertainty, uncertainty number, interval arithmetic, Mathematica
1. Introduction
The concept of uncertainty is relatively new, although error and error analysis have long been a part of science. There
is international consensus on the evaluation of standard uncertainty and combined standard uncertainty in measurement
and computations. Just as the International System of Units (SI) has brought coherence to all scientific and technological
measurements, the worldwide consensus on uncertainty permitted a vast spectrum of results to be readily understood and
properly interpreted (see EAL(1997) and ISO(1995)).
The needs of numerous testing laboratories to calculate the measurement uncertainty in a large scale is supported
by numerous software tools. Rasmussen(2003) reweaved ten different software packages. The reader can get more
information related to them directly from the internet links given in the list of references (4 to 13).
To facilitate the calculation of the combined standard uncertainty, similarly to the complex and interval numbers, this
paper introduce a new object x x called uncertainty number. The corresponding uncertainty calculus is implemented
by the authors as a Mathematica package (see www.wolfram.com). The uncertainty calculus transform a functional
relationship of uncertainty numbers f [x1 x1 , x2 x2 , ..., xn xn ] into an uncertainty number y y, assuming
that all input quantities xi ui are independent.
The traditional uncertainty concept focus on an unknowable error and true value using the so called general law of
error propagation. The new concept is based on the estimated value and uncertainty using the same law of uncertainty
propagation. Only the interpretation is different. Regardless which concept is adopted, the uncertainty calculus could be
used.
This paper briefly describes the uncertainty calculus implemented in a Mathematica package. Examples demonstrating
the uncertainty calculus are given. In addition, the new dynamic interactive computing, introduced by Wolfram Research
with the release of Mathematica 6, is demonstrated by one example. The input quantities and their uncertainties are varied
in predefined ranges by using sliders. The final results and its uncertainty are automatically updated to always reflect the
current input. This text is generated from Mathematica 6 notebook.
2. Uncertainty Calculus
The ISO guide (ISO (1995), Annex E, p.46) gives justification to treat all uncertainty components identically. Let
the output quantity z = f (w1 , w2 , ..., wn ) depends on n input quantity w1 , w2 , ..., wn , where each wi is described by an
appropriate probability distribution. Expansion of f about the expectations of the wi , E(wi ) = i , in a first-order Taylor
series yields for small deviations of z about z in terms of small deviations of wi about i ,

z z =

n
X
f
(wi i ),
wi
i=1

where all higher-order terms are assumed to be negligible and z = f (1 , 2 , ..., n ).


The square of the deviation (z z ), when all input quantities w1 , w2 , ..., wn are independent, may be written as

(1)

Proceedings of ENCIT 2008


c 2008 by ABCM
Copyright

(z z )2 =

12th Brazilian Congress of Thermal Engineering and Sciences


November 10-14, 2008, Belo Horizonte, MG

2
n 
X
f
(wi i )2 .
w
i
i=1

(2)

The expectation of the squared deviation (z z )2 is the variance of z, that is, E[(z z )2 ] = z2 and Eq. (2) leads
to

z2

2
n 
X
f
=
i2 .
w
i
i=1

(3)

If each standard deviation in Eq. (3) is replaced by the multiple ki , with the same k for each i , the standard deviation
of the output becomes kz .
The ISO guide (ISO (1995), p. 9-10) consider a quantity Y determined from n other quantities X1 , X2 , ..., Xn ,
through a functional relationship f :
Y = f [X1 , X2 , ..., Xn ].

(4)

The input quantities X1 , X2 , ..., Xn , upon which the output quantity Y depends may themselves depend on other
quantities thereby leading to a complicated functional relationship f .
An estimate of the quantity Y , denoted by y, is obtained from Eq. (4) using input estimates x1 , x2 , ..., xn , for the
values of the n quantities X1 , X2 , ..., Xn . Thus the output estimate y, is given by
y = f [x1 , x2 , ..., xn ].

(5)

The estimated standard deviation associated with the output estimate y, termed combined standard uncertainty and
denoted by uc , is determined from the estimated standard deviation associated with each input estimate Xi , termed
standard uncertainty and denoted by ui .
The combined standard uncertainty uc is an estimated standard deviation characterizing the dispersion of the values
that could reasonably be attributed to a quantity Y . According to Eq. (3), valid for independent input quantities, the
combined standard uncertainty is the positive square root of the combined variance given by the ISO guide (ISO (1995),
5.1.2, p. 19):

u2c =

2
n 
X
f
i=1

xi

u2i .

(6)

It is easy to compute the numerical value of the function for variables with known numerical values xi = vi . However,
the experimental results are not the same when an experiment is repeated. In practice, the principles of statistical inference
are used to establish a confidence interval, giving a bound within each values is expected to lie with a certain probability.
Thus, we assume that for every vi the confidence interval or uncertainty ui is known.
The uncertainty in a value y computed from Eq. (6) when xi = vi ui for known values vi and uncertainties ui is
called propagation of error. To compute error propagation, Mathematica software system, starting from Version 3, use
interval numbers that represent uncertainty values xi which lies somewhere in the interval xi,min to xi,max . In operations
on intervals that involve approximate numbers, Mathematica always rounds lower limits down and upper limits up.
Similarly to the complex and interval numbers, we introduce a new object v u called uncertainty number, where v
and u are a value and its uncertainty, respectively. The uncertainty calculus transforms an arbitrary functional relationship
of uncertainty numbers f [x1 u1 , x2 u2 , ..., xn un ] into an uncertainty number y uc using Eq. (6). The developed
Uncertainty Calculus compute an arbitrary expression F by using the general law of uncertainty propagation:
v
u n

2
uX
F [v1 ...vn ]
2
t
ui
F [v1 u1 , v2 u2 , ..., vn un ] = F [v1 ...vn ]
.
xi
i=1

(7)

In addition, the Eq.(7) has been implemented in a function Uncertainty with arguments expression and list of elements
(variable, value, uncertainty). This function gives a value uncertainty for the expression. The option InfluenceTrue

Proceedings of ENCIT 2008


c 2008 by ABCM
Copyright

12th Brazilian Congress of Thermal Engineering and Sciences


November 10-14, 2008, Belo Horizonte, MG

gives the influences of the variables on the uncertainty in %. The Uncertainty function has been used to check most of the
results obtained directly by using uncertainty calculus.
The uncertainty calculus is implemented in a Mathematica package. The default Uncertain option Symbol False,
manipulates numerical uncertainty numbers while Symbol True manipulates also symbolic uncertainty numbers.
The uncertainty calculus is similar to the interval arithmetic. The uncertainty calculus gives the more probable uncertainty, while the interval arithmetic gives the maximal uncertainty. To make easier the comparison between these two
techniques we have implemented the functions ToInterval and ToUncertain transforming uncertainty in interval numbers
and vice versa. Although the principles of interval computing may seem obvious or even trivial, there are gotchas, as
mentioned by Hayes (2003). Some of the pitfalls described in Hayes (2003) appears also in the uncertainty calculus.
Computer programs rely heavily on comparisons. Whereas there are just three elementary comparisons for pointlike
numbers (<, = and >), there are as many as 18 well-defined relations for intervals. It is not always obvious which one to
choose, or even how to name them (Hayes (2003)). We assume that an uncertainty number v u has much bigger value
than uncertainty v  u. Than the Mathematica functions Greater, GreaterEqual, Less, LessEqual, SameQ, Unequal,
UnsameQ, Negative, NonNegative, NonPositive, Positive of an uncertainty number neglects its uncertainty.
3. Calculating functions of symbolic uncertainty numbers
The uncertainty calculus has been used to calculate numerous expressions of symbolic uncertainty numbers. The
results coincide with the one obtained by the function Uncertainty. Some of the results are:
q
va ua + vb ub = va + vb u2a + u2b ,
p
(va ua )(vb ub ) = va vb (ub va )2 + (ua vb )2 ,
expva ua = expva expva ua
log(va ua ) = log(va ) ua /va ,
sin(va ua ) = sin(va ) ua cos(va ),
cos(va ua ) = cos(va ) ua sin(va ),
J0 (va ua ) = J0 (va ) ua J1 (va ),
Y0 (va ua ) = Y0 (va ) ua Y1 (va ).

(8)
(9)
(10)
(11)
(12)
(13)
(14)
(15)

4. Calculating expressions of numeric uncertainty numbers


The uncertainty calculus has been used to calculate expressions of numeric uncertainty numbers. Let us consider two
examples from the book by Taylor (1977).
The first example deal with mixing liquids in two flask. Suppose an experimentalist mixes together the liquids in two
flasks, having first measured their separate masses in grams when full and empty, as follows (Taylor (1977), p. 50):
M1 = 540 10;

m1 = 72 1;

M2 = 940 20;

m2 = 97 1.

(16)

The answer given in Taylor (1977) is M = 1310 30, while uncertainty calculus gives:
M = M1 m1 + M2 m2 = 1311 22.4054.

(17)

The second example handlespwith the measurement of the gravitational acceleration. Suppose we measure the length
L in cm and the period T = 2 L/g in s of a simple pendulum (Taylor (1977), p. 57):
L = (92 0.1);

T = (1.936 0.004).

(18)

The answer in Taylor (1977) is 979 4 cm/s2 , while uncertainty calculus gives:
g = (2/T )2 L = 969.029 4.14047.

(19)

5. Plotting uncertainty numbers


The built-in ListPlot function has been extended to plot a list of points (xi , yi ui ) which ordinates the are uncertainty numbers. Figure 1 shows a list of points created for x = 0 to x = 2 in steps of /48 and y = sin(x)
RandomReal[0, 0.2].

Proceedings of ENCIT 2008


c 2008 by ABCM
Copyright

12th Brazilian Congress of Thermal Engineering and Sciences


November 10-14, 2008, Belo Horizonte, MG

Figure 1: Plot of the function sin(x) with randomly generated uncertainty (-0.2 to 0.2).

5.1 Function FindRoot


Some Mathematica functions, like Solve and LinearSolve, works with uncertainty numbers. Since the built-in FindRoot is protected against not standard numbers, it didnt accept equations having the new uncertainty numbers. For this
reason we have implemented the well-known Newton iteration method. The starting point x = 0.1 for the equation
cos(x) = (5 0.25)x sin(x) gives 0.432841 0.115294. The minimum uncertainty part of the root appears when the
starting point is obtained by the built-in FindRoot for the equation cos(x) = 5x sin(x) as 0.432841 0.0101285.
6. Dynamic interactive computing
Finally, the new dynamic interactive computing, introduced by Wolfram Research with the release of Mathematica 6
is demonstrated.
As an example, let us compute the density of mist air, given by the empirical formula (Davis (1992)):

A =

k1 p k2 hr exp(k3 t)
,
k4 + T

(20)

where A (kg m3 ) is the air density, T (o C) is the air temperature, p(hP a) is the barometric pressure, hr (%) is the
relative humidity of air and k1 = 0.34848, k2 = 0.009, k3 = 0.061, k4 = 273.15.
The uncertainty calculus package permitted to compute directly from Eq.(8) the air density and its uncertainty after
replacing T , p, and hr by the corresponding numerical uncertainty numbers. To create interactive dynamic object it is
better to derive from Eq.(8) an analytical formula. After replacement of the air temperature, barometric pressure, and
relative humidity by the symbolic uncertainty variables T T , p p, hr hr , the uncertainty calculus gives:
A A = K

(k1 p)2 + (KT )2 + exp2k3 t k22 (h2r + (hr k3 T )2 )/(k4 + T ),

(21)

where
K = (k1 p hr k2 expk3 T )/(k4 + T ).

(22)

The Eqs. (8) and (9) have been used to create the dynamic interactive computing object presented in Fig. 2.
The input quantities and their uncertainties can be varied by using the sliders shown in Fig. 2. If you click on the
squares before the number you could open and close a slider. When the slider is open, as the temperature slider of Fig.
2, you could click on the plus or minus to move the slider one step. The air density and its uncertainty are automatically
updated to always reflect the current positions of the slider.
7. Conclusions
This paper describes the first steps in the creation of an uncertainty calculus similar to the interval arithmetic, but
based on the general law of uncertainty propagation. The interval arithmetic gives the maximum uncertainty, while the
uncertainty calculus gives the more probable error that may occur in a measurement.
Our Mathematica package evaluate arbitrary expression including numerical or symbolic uncertainty numbers written
as x x . A lot of work has to be done in comparing the uncertainty calculus and the interval arithmetic. We have tested
and adopted only a few Mathematica functions. Many other functions have to be adopted.

p,

and hr by the corresponding numerical uncertain numbers. To create interactive dynamic object it is better to derive from

eq.(8) analytical formula. After replacement of the air temperature, barometric pressure, and relative humidity by the symbolic uncertain variables t 't, p 'p, and hr 'hr , the uncertain calculus gives:

Proceedings of ENCIT 2008


c 2008 by ABCM
Copyright

UA 'UA

+k1 'p/2  +K 't/2  2 k3 t k2 2 ,'hr 2  +hr k3 't/2 0 v +k4  t/

where
K

(18)

12th Brazilian Congress of Thermal Engineering and Sciences


November 10-14, 2008, Belo Horizonte, MG

,k1 p  hr k2 k3 t 0 t +k4  t/

(19)

The formulae (8) and (9) has been used to create the following dynamic interactive computing object:

Temperature T #C'

20.8

Uncertainty T #C'

0.01

Barometric pressure p #hPa'

1008

Uncertainty p #hPa'
Relative umidity h #'
Uncertainty h #'

MoistAirDensity

0.9
45.1
2

1.19008 0.00108971 kgsm^3

quantities of
and atheir
uncertainties
can be varied by
using sliders. If
you click
on the
before the number you
FigureThe
2:input
Example
dynamic
interactive
computing
object
and
itssquares
sliders.

could open and close a slider. When the slider is open, as the temperature slider above, you could click on the plus or minus
to move the slider one step. The air density and its uncertainty are automatically updated to always reflect the current
positions of the slider.

The uncertainty calculus and dynamic interactive computing are general purpose technology that could be applied not
only in metrology, but in any other scientific area.
8. Acknowledgements
M. Mikhailov is grateful to the National Institute of Standards (DINAM/INMETRO) for the award of a Research
Fellowship.
9. References
EAL (European cooperation for Accreditation of Laboratories), 1997, Expression of the Uncertainty of Measurement in
Calibration, EAL-R2 and EAL-R2-S1
ISO (International Organization for Standardization), 1995, Guide to the Expression of Uncertainty in Measurement,
Switzerland, ISBN 92-67-10188-9
Sven Nytoft Rasmussen, 2003, Software tools for the expression of uncertainty in measurement,
http://www.danishtechnology.dk/calibration/9156
Integrated Sciences Group, UncertaintyAnalyzer, http://www.isgmax.com/uncbroc.htm
Chris Grachanen, 2002, Uncertainty Calculator, http://metrologyforum.tm.agilent.com/download3.shtml
GUM Workbench, http://www.gum.dk. http://www.metrodata.de
Danish Institute for Fundamental Metrology DFM-GUM, http://www.dfm.dtu.dk/en/dfm-gum.html
WINCERT, http://www.implex.fr/wincert.htm
Assistant, http://www.inframet.pl/uncertainty underscore calculators.htm
Uncertainty Pro, http://www.chemistry-software.com/quality/16032.htm,
http://www.chemsw.co.kr/quality/16032.htm
Timeko Uncertainty, http://www.timeko.com
EMPA, Uncertainty Manager published by EMPA,
http://www.uncertaintymanager.com,
http://www.empa.ch/plugin/template/empa/*/17463
Newton Metrology Inc., Evaluator, http://personal.zahav.net.il/PersonalSite/nm/nmetro/evaluator.htm,
http://metrologyforum.tm.agilent.com/download8.shtml
Mathematica software system, www.wolfram.com
Davis, R.S., 1992, Equation for the determination of the density of mist air, (1981/91), Metrologia, 29, 67.
J. R. Taylor, 1977, An introduction to Error Analysis: The study of uncertainties in physical measurements, University
Science Books

Brian Hayes, 2003, A lucid interval, American Scientist, Volume 91, Number 6, NovemberUDecember,
pages 484488

You might also like