## 10 February 2013

### Developing an uncertainty calculation with GTC

The traditional approach to uncertainty calculation described in the GUM requires a mathematical model of the measurement
$Y = f(X_1, X_2,\cdots)$
where $$Y$$ is the measurand and $$X_1, X_2,\cdots$$ are all the quantities that can influence the outcome of the measurement. Usually, it is difficult to write down this function directly.

GTC also works with a model, but instead of writing down a single function that depends on everything, we can build models in smaller, convenient steps.

An example should make this clearer.

Consider a measurement of current through a standard resistor (also called current shunt) made using a voltmeter, as shown

If the resistance $$R$$ of the current shunt is known, $$I$$ can be calculated using Ohm's law
$I = \frac{V}{R}$
Four voltage readings have been recorded (all in mV)
$100.6512 \,, \; 100.6401 \,, \; 100.6420 \,, \; 100.6101 \,,$
and the resistor has been calibrated
$R = 0.009011 \, {\Omega} \quad \frac{u(R)}{R} = 0.0003$
So the current can be calculated using uncertain numbers for the voltage and resistance estimates
x_obs = [100.6512E-3, 100.6401E-3, 100.6420E-3, 100.6101E-3]
V = type_a.estimate(x_obs,label='V_type_a')

e_R_cal = ureal(1,0.0003,label='e_R_cal')
R = 0.009001 * e_R_cal

I = V/R
I.label = 'I'
print summary(I)

The result (in amperes) is
I: 11.1805, u=0.0035, df=465.6

### Enhancing the model: temperature dependence

Suppose now that, during measurements, the temperate was controlled only to within $$\pm 3^\circ \mathrm{C}$$ of the reported calibration temperature. This means that the value of $$R$$ may be slightly different from the one reported. To allow for this, an additional component of uncertainty in the resistance due to temperature should be added to the model.

Given the current-shunt temperature coefficient $$\alpha = 4 \times 10^{-6}\; \Omega/ {^\circ \mathrm{C}}$$, and the temperature range, we may modify the model of the measurement by simply writing
e_R_T = ureal(1,4E-6*type_b.uniform(3),label='e_R_T')
R = 0.009001 * e_R_cal * e_R_T

Repeating the calculation
I = V/R
I.label = 'I'
print summary(I)

we obtain the same result
I: 11.1805, u=0.0035, df=465.6
Apparently, the temperature does not have a big influence. To investigate further, we can look at the uncertainty budget for $$I$$
for cpt in reporting.budget(I,trim=0):
print "%s: %G" % cpt

This displays the magnitude of the component of uncertainty in $$I$$ due to each of the three influence quantities
e_R_cal: 0.00335416
V_type_a: 0.000990883
e_R_T: 7.74609E-05

### Enhancing the model: voltmeter errors

Another source of measurement error will be the voltmeter accuracy. In other words, the voltage indicated will not be exactly the same as the applied voltage. Voltmeter errors can be represented as
$x_\mathrm{dis} = (1 + e_\mathrm{gain}) V + e_\mathrm{zero}$
where $$x_\mathrm{dis}$$ is the reading shown when a voltage $$V$$ is applied: $$e_\mathrm{zero}$$ is an offset error (i.e., the reading when $$V=0$$ ) and $$e_\mathrm{gain}$$ is a gain (i.e., the reading is not exactly $$1 \times V$$ ).

The voltmeter specifications give an voltage offset error uncertainty of $$500 \,\mu V$$ and a gain (scale) error uncertainty of $$25 \times 10^{-6} \,V/V$$. Each error contributes to the uncertainty in $$x_\mathrm{dis}$$  as an estimate of the voltage $$V$$.

The measurement model can be extended by adding two more uncertain numbers
e_gain = ureal(0,25E-6,label='e_V_gain')
e_off = ureal(0,500E-6,label='e_V_off')
V = (type_a.estimate(v_obs,label='V_type_a') - e_off ) /(1 + e_gain)

Note that these new uncertain numbers have been combined with the type-A estimate of voltage, obtained from the observations. This is OK, because the errors are systematic (they do not change during the four repeat voltage readings), so the effect they have on the average voltage is the same as on each individual reading (however, a future post will show another way of introducing handling this type of problem).

Recalculating the current now
I = V/R
I.label = 'I'
print summary(I)
for cpt in reporting.budget(I,trim=0):
print "%s: %G" % cpt

we obtain
I: 11.181, u=0.056, df=inf

e_V_off: 0.0555494
e_R_cal: 0.00335416
V_type_a: 0.000990883
e_V_gain: 0.000279513
e_R_T: 7.74609E-05

In this case, the voltmeter offset uncertainty makes a significant contribution to the current measurement.

### Putting it all together

The GTC code now looks like this:
e_R_cal = ureal(1,0.0003,label='e_R_cal')
e_R_T = ureal(1,4E-6*type_b.uniform(3),label='e_R_T')

R = 0.009001 * e_R_cal * e_R_T

x_obs = [100.6512E-3, 100.6401E-3, 100.6420E-3, 100.6101E-3]

e_gain = ureal(0,25E-6,label='e_V_gain')
e_off = ureal(0,500E-6,label='e_V_off')

V = (type_a.estimate(x_obs,label='V_type_a') - e_off ) /(1 + e_gain)

I = V/R
I.label = 'I'

print summary(I)

for cpt in reporting.budget(I,trim=0):
print "%s: %G" % cpt

Try to imagine writing down the measurement model for this problem as a simple function $$f()$$. It is not straight forward.

Using GTC, on the other hand, builds the model implicitly, as the different contributions to measurement uncertainty are introduced. Also, as shown in this post, the model can be easily expanded, or simplified, by adding or removing uncertain numbers from the calculation.

That makes GTC a very convenient tool for doing simple uncertainty calculations.