## Software

Uncertain-number software takes care of the mathematical details involved in calculating measurement uncertainty.

It is an example of computational thinking: a tool for formulating problems in a way that they can be tackled by computers.

To use uncertain-number software, the measurement procedure must be clearly defined, so all sources of measurement error have been identified and quantified and the relationship between these quantities and the measurand is well-defined (see Theory). But that, of course, is a prerequisite for any uncertainty analysis.

Uncertain numbers represent quantity estimates, encapsulating the associated standard uncertainties and degrees of freedom. Uncertain numbers representing influence quantities can be manipulated directly to obtain an uncertain-number estimate of the measurand, as well as uncertain-number estimates of any intermediate quantities.

## Example: a simple power measurement

Consider the measurement of electrical power in a resistive element. Power is related to potential difference $$V$$ across the element and the resistance of the element $$R$$ $P = \frac{V^2}{R} \; .$ Let's say that our estimate of $$R$$ from measurement is $$r=150 \, \Omega$$, with a standard uncertainty $$u(r)=1\,\Omega$$ and degrees of freedom $$\nu_r=15$$. Also, $$V$$ is estimated as $$v=76 \, \mathrm{mV}$$, with a standard uncertainty $$u(v)=0.1\,\mathrm{mV}$$ and degrees of freedom $$\nu_v=50$$.

The calculation of $$p$$, our estimate of $$P$$, can be carried out using the GTC calculator as follows.

r = ureal(150, 1, 15, label='r')
v = ureal(76*1E-3, 0.1*1E-3, 50, label='v')

p = v**2/r

print summary(p)

The result displayed is
3.851E-05, u=2.8E-07, df=19.9

showing that $$p=3.851 \times 10^{-5} \, \mathrm{W}$$, with standard uncertainty $$u(p)=2.8 \times 10^{-7}\, \mathrm{W}$$ and degrees of freedom $$\nu_p=19.9$$.

An expanded uncertainty interval for this measurement, with a level of confidence of 95%, can be obtained

U = reporting.uncertainty_interval(p)

print "[{0.lower:.7f},{0.upper:.7f}]".format(U)

which displays
[0.0000379,0.0000391]

(The double ** operator in v**2/r squares the uncertain number representing voltage and the complicated formatting in the print statement are both features of the Python programming language used by GTC.)

The respective contributions to the combined standard uncertainty made by the resistance and voltage measurements is indicated by the corresponding uncertainty components magnitudes, $$|u_r(p)|$$ and $$|u_v(p)|$$. In GTC these are obtained directly

print component(p,r), component(p,v)

which displays
2.56711111111e-07    1.01333333333e-07

and shows that resistance measurement is the dominant source of uncertainty. Another way of presenting the whole uncertainty budget is

for cpt in reporting.budget(p):
print " {0.label}: {0.u:.8f}".format(cpt)

which displays
r: 0.00000026
v: 0.00000010

(Here r and v are the labels that were assigned to the uncertain numbers for the resistance and voltage measurements.)