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.

Measurements and their uncertainty

Pre/Post-test

This test is for testing your current skills in Python. You can use it in two ways:

  • pre-test: to test your skills beforehand. If you are already proficient in Python, and can do this test within approximately 15 minutes, you can scan through the notebook rather than carefully reading each sentence.

  • post-test: test your skills after Notebook 6. Check whether you learned enough.

Diode

In an experiment, 10 measurements were taken of the voltage over and current through a Si-diode. The results are displayed in the following table, together with their uncertainties:

I (μA)u(I)u(I) (μA)V (mV)u(V)u(V) (mV)
303446704
149426364
756.10.86044
384.90.45724
199.50.35414
100.60.25054
39.930.054653
20.110.034323
10.230.024003
5.000.013653
2.5560.0083313
1.2690.0072962
0.6010.0072572
0.2950.0062212
0.1370.0061812
0.0670.0061452

The diode is expected to behave according to the following relation: I=a(ebV1)I = a(e^{bV}-1), where aa and bb are unknown constants.

Exercise: Use the curve_fit function to determine whether this is a valid model to describe the dataset. Is the value found for parameter aa in agreement with the value found in another experiment a2=2.0±0.5nAa_{2} = 2.0 \pm 0.5 \mathrm{nA}?

Hint: use a logscale on the y-axis

import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit

I = np.array([3034,1494,756.1,384.9,199.5,100.6,39.93,20.11,10.23,5.00,2.556,1.269,0.601,0.295,0.137,0.067])*1e-6
a_I = np.array([4,2,0.8,0.4,0.3,0.2,0.05,0.03,0.02,0.01,0.008,0.007,0.007,0.006,0.006,0.006])*1e-6
V = np.array([670,636,604,572,541,505,465,432,400,365,331,296,257,221,181,145])*1e-3
a_V = np.array([4,4,4,4,4,4,3,3,3,3,3,2,2,2,2,2])*1e-3

Learning objectives

Now that we’ve learned the basics of Python, it’s time to apply it to explore features and understand the nature of physical measurements.

In this notebook, we will introduce you to measurements, variance in repeated measurements, and measurement uncertainties. When performing calculations with values that include uncertainties, the results also carry uncertainties — but how do we calculate them? Moreover, we often do not work with a single set of repeated measurements but with datasets containing several mean values of repeated measurements. How do we properly analyze such data?

For each topic, a summary is given. What is new, compared to the previous notebooks, is that we have * assignments. These are not mandatory, but can be made to help you improve your knowledge of Python and data-analysis.

Now that we know how to do some basic Python, it is time to use it to understand features of physical measurements. It is very useful to study the chapter in the online manual as well!

After completing this notebook, you are able to:

  • calculate the mean, standard deviation and uncertainty of a dataset

  • report findings using the scientific conventions

  • understand and use Gaussian and Poisson distribution

  • identify outliers

  • carry out an agreement analysis

  • calculate how uncertainties propagate when calculations are performed

Introduction

In physics experiments, you try to determine relationships or certain values as accurately as possible. What “as accurately as possible” actually means remains unclear for now. What should already be clear is that we can almost never determine such values directly. Instead, we conduct experiments to collect data, which we then use to determine the relationship and establish its parameters as accurately as possible.

However, it is never possible to determine the exact value(s) of those parameters. Each new measurement will show small fluctuations, especially when measuring with high precision. Over time, we have been able to improve our experiments and take more measurements in less time. This means that, over the course of history, constants such as Planck’s constant have been determined with increasing accuracy and that the value has varied over the years.

The consequence of never being able to determine a value exactly is that any result based on it will also carry uncertainty. It will always be uncertain what the exact value actually is. In this chapter, you will learn how the uncertainty in a measured value affects the final result (you already know the basics, significant figures and associated calculation rules), and how to minimize that uncertainty.

Goal

A complete data analysis will often consist of the following three phases:

  1. determining the reliability of individual measurements and the dataset as a whole;

  2. finding and determining the pattern in the data, including determining the variables with their associated uncertainties;

  3. an optimal data (re)presentation to convince of phases 1 & 2.

The aim of this part of the physics practical is to develop a deeper understanding of the above phases and to learn how to apply the associated techniques.

Quantities, units, dimension-analysis and constants

In physics, we measure physical quantities. We distinguish between vectors (quantities with a direction F\vec{F} (N)) and scalars (quantities with only a value (m(kg)m (\mathrm{kg}))). The quantity is written in italics (UU), with the corresponding unit in upright type (V\mathrm{V}).

Units are standardized by the International System of Units (SI). The five SI-units we use most are kg,m,s,K\mathrm{kg, m, s, K} and A\mathrm{A}. There is also a sixth and seventh standard unit that you encounter less often (cd\mathrm{cd}) and (mol\mathrm{mol}). All other units are derived from these standard units. You can obtain the SI representation of any derived unit by substituting the base-unit dimensions into the defining formula. For example, power equals force times velocity:

Similarly, based on units (dimensional analysis), you can derive formulas if you know which quantities may play a role. This will be discussed in much greater depth in the second-year course Physical Transport Phenomena. Would you like to know how to perform a dimensional analysis? Then take a look at this video:

In many experiments in which you determine a relationship, you use a constant, such as Planck’s constant. CODATA has compiled a useful list of these constants with their corresponding (relative) uncertainty. Use this reference when looking up and using physical constants.

Provided the equation F=kv2F=k \cdot v^2, what is the unit of kk expressed in SI-units (kg, m, s, A, K)?

Solution to Exercise 1

F=kv2F = k \cdot v^2 k=Fv2\rightarrow k = \frac{F}{v^2} [k]=[kgms2m2s2][k] = [\frac{\mathrm{kg} \frac{\mathrm{m}}{\mathrm{s}^2}}{\frac{\mathrm{m}^2}{\mathrm{s}^2}}] [k]=[kgm][k] = [\frac{\mathrm{kg}}{\mathrm{m}}]

Errors and uncertainties in experimental physics

Every measurement of a physical quantity comes with a certain degree of uncertainty. This is simply because the act of measuring influences what you are measuring. Two examples of this are given in Figure 1 and Figure 2. Placing a voltmeter in an electrical circuit inherently changes the original electrical circuit. Placing a pressure gauge (Venturi tube) in a liquid flow influences the original setup and thus the liquid flow.

Measuring voltage already changes the electric ciruit itself.

Figure 1:Measuring voltage already changes the electric ciruit itself.

Placing pressure gauges in a liquid flow affects the original flow.

Figure 2:Placing pressure gauges in a liquid flow affects the original flow.

Systematic error

In addition to influencing the measurement of your physical quantity by measuring it, there are other causes that can lead to ‘errors’. We distinguish between systematic errors and random errors. A systematic error will always be the same size, and therefore causes a deviation in your average result. Such an error strongly influences your final result. Fortunately, you can correct for this type of error. Examples of systematic errors are a zero point error and a calibration error, see for example Figure 3.

This creates a systematic error if you are not aware that the ruler does not start at 0.

Figure 3:This creates a systematic error if you are not aware that the ruler does not start at 0.

To find out whether there is a systematic error in your data, you can check this using Python, for example. This is best explained using an example.

In Figure 4, you can see the difference between a fit with and without compensation for systematic error. Although the upper figure appears to be a good fit, you can see that the fit in the lower figure is even better across all measurements. Later, we will look at how we can investigate such errors more systematically.

Least-squares curve fit without correction for the systematic error: F = \frac{a}{r^4}

Figure 4:Least-squares curve fit without correction for the systematic error: F=ar4F = \frac{a}{r^4}

Least-squares fit with correction for the systematic error: F = \frac{a}{(r+\Delta r)^4} It is clear that the curve fits with all data.

Figure 5:Least-squares fit with correction for the systematic error: F=a(r+Δr)4F = \frac{a}{(r+\Delta r)^4} It is clear that the curve fits with all data.

Random error

A random measurement error can arise due to, for example, temperature fluctuations, vibrations, air currents, collisions at the molecular level, etc. This is referred to as a technical random error. These uncertainties cannot always be reduced. Random errors can be both positive and negative, and therefore average out if you take enough measurements. You can work with them and calculate them because they are based on a probability distribution. In the following sections, we assume that you are always dealing with a random error, i.e., an error that is not correlated with other variables and for which the probability of that error occurring is normally (Gaussian) distributed.

In addition to technical random errors, you may encounter fundamental errors due to physical limitations on some measurements, for example due to thermal fluctuations when measuring currents. This is referred to as a fundamental random error. This contribution to the measurement uncertainty cannot be reduced. The contribution to the total uncertainty can be either positive or negative.

Instrumental uncertainties

Every instrument you use has certain limitations. The uncertainty may be dependent on reading the instrument, but also on the instrument itself, or on the value of the measured quantity. In addition, you must first calibrate (some) instruments before using them. An error in calibration can lead to a systematic error.

When using instruments, the terms precision and accuracy are often used. Precision refers to the small spread in the measurements. Precision is closely related to random errors. Accuracy refers to how close the measurements are to the desired value. Accuracy is closely related to systematic errors. The four variants that you can have are shown in Figure 6.

The four variants concerning accuracy and precision. Accuracy is strongly linked to systematic errors, precision to random errors.

Figure 6:The four variants concerning accuracy and precision. Accuracy is strongly linked to systematic errors, precision to random errors.

Measurement uncertainty in analog instruments
With analog instruments, you have to read the value, see Figure 7. In some cases, there is a mirror behind the pointer so that you don’t make a mistake by reading the pointer at an angle. Furthermore, you cannot read the value with infinite precision. Think of a measuring stick that allows you to measure accurately to the nearest millimeter, but where distances between millimeters cannot be determined accurately, especially when the lines on the ruler are thick. When reading an analog meter, you must estimate the associated uncertainty:

  • Read the value as accurately as possible.

  • Determine the values that you can still read accurately.

  • Then take half of the difference between two values that you can accurately read as a measure of uncertainty.

As you can see, there are not always fixed rules for determining measurement uncertainty, and sometimes it comes down to common sense and reasoning how you arrive at that value.

Reading an analog meter where the first decimal place must be estimated based on interpolation.

Figure 7:Reading an analog meter where the first decimal place must be estimated based on interpolation.

Measurement uncertainty in digital instruments
When reading a digital instrument, see Figure 8, you would say that the uncertainty lies in the last decimal digit shown. However, the uncertainty of digital instruments is much greater than the last decimal digit; just think of the uncertainty when using a stopwatch. For devices used in physics practicals, this uncertainty is sometimes even determined by the age of the device and the time it has been switched on (warming up). For many digital (expensive) devices, the specifications state exactly how the measurement uncertainty should be calculated.

The digital multimeter determines the “exact” value of a 33 kΩ (5% tolerance) resistor.

Figure 8:The digital multimeter determines the “exact” value of a 33 kΩ (5% tolerance) resistor.

Mean, standard deviation and standard error

Because measured values can fluctuate, the average of a series of repeated measurements (xix_i) provides the best possible approximation of the actual value. The average value is calculated based on the series of repeated measurements:

μx=x=x1+x2+x3+...+xnN=1Ni=1Nxi\mu_x=\overline{x} = \frac{x_1 + x_2 + x_3 + ... + x_n}{N} = \frac{1}{N}\sum_{i=1}^{N} x_i

Of course, a repeated measurement only makes sense if your instrument is accurate enough to show variations. There is a degree of dispersion in the series of measurements: the measurements differ from each other. The standard deviation is a measure of that dispersion:

σ(x)=i=1N(xix)2N1\sigma(x) = \sqrt{\frac{\sum_{i=1}^N (x_i-\overline{x})^2}{N-1}}

Although the mean and standard deviation are better defined with more measurements, the standard deviation does not decrease in value, see Figure 9. The spread itself is therefore not a good measure of the uncertainty in your mean value. The uncertainty in your mean is given by:

u(x)=σ(x)Nu(x) = \frac{\sigma(x)} {\sqrt{N}}

An important insight is that the measurement uncertainty decreases with the square root of the number of measurements. To reduce the measurement uncertainty based on multiple measurements by a factor of 10, you need to perform 100 times as many repeated measurements. The optimum number of repeated measurements therefore depends on (1) the accuracy you want to achieve, and (2) the time and money you have available to achieve that accuracy.

Noise generation shown as points and in a histogram. Bottom left the standard deviation (convergent) and bottom right the measurement uncertainty (decreases with \frac{1}{\sqrt{N}}).

Figure 9:Noise generation shown as points and in a histogram. Bottom left the standard deviation (convergent) and bottom right the measurement uncertainty (decreases with 1N\frac{1}{\sqrt{N}}).

The measurement uncertainty is equal to the deviation of the mean of repeated experiments. That is, if the entire experiment is repeated, there will always be a difference in the determined mean. The standard deviation of this mean is equal to u(x)u(x), or, there is a roughly 2/3 chance that when the entire experiment is repeated, the average will lie between x±u(x)\overline{x} \pm u(x). The code below shows how you could verify this statement.

The to be reported value you use is written as:

Measurement±uncertainty+unit\mathrm{Measurement} \pm \mathrm{uncertainty} + \mathrm{unit}

The uncertainty determines the number of significant digits to be used. You use the same number of decimal digits.

Determine the mean, standard deviation and standard error of the next measurement series:

  1. 0.10; 0.15; 0.18; 0.13

  2. 25; 26; 30; 27; 19

  3. 3.05; 2.75; 3.28; 2.88

Solution to Exercise 2
  1. x\overline{x}=0.14, σ\sigma = 0.034, u(x)u(x) = 0.02

  2. x\overline{x}=25.4, σ\sigma = 4.0, u(x)u(x) = 2

  3. x\overline{x}=2.99, σ\sigma = .23, u(x)u(x) = 0.1

Weighted average

It may happen that not all repeated measurements are equally reliable. If measurement 1 has half the uncertainty of measurement 2, then it seems logical that the average is calculated by 2x1+1x23\frac{2 \cdot x_1 + 1 \cdot x_2}{3}. We then refer to this as a weighted average. The question is, of course, how to determine the reliability and how to arrive at our weighting factor. Fortunately, we have just found a measure for this, namely the measurement uncertainty. The weighting factor is defined by:

wi=1u(xi)2w_i = \frac{1}{u(x_i)^2}

The weighted average becomes:

x=w1x1+w2x2+w3x3+...+wnxnw1+w2+w3+...+wn=i=1Nwixii=1Nwi.\overline{x} = \frac{w_1 x_1 + w_2 x_2 + w_3 x_3 + ... + w_n x_n}{w_1 + w_2 + w_3 + ... + w_n} = \frac{\sum_{i=1}^{N} w_i x_i}{\sum_{i=1}^{N} w_i}.

with an associated uncertainty of:

u(x)=1iNwiu(x) = \sqrt{\frac{1}{\sum_i^N{w_i}}}

Note that the above formula reduces to the normal mean if all weighting factors wiw_i are equal to 1.

In an experiment during physics lab, the acceleration due to gravity is determined. This yields the following values for different groups: 9.814 ± 0.007, 9.807 ± 0.003, 9.813 ± 0.004.

Calculate the weighted average and the corresponding uncertainty.

Solution to Exercise 3

9.809 ± 0.002 m/s²

Note that the uncertainty in the final answer has decreased!

Probability distributions

As indicated, there is variation in repeated measurements. We can view the physical measurement MM as the sum of the physical value GG and noise ss:

M=G+sM = G + s

Noise is broadly defined here; we understand it to mean all possible errors. We are particularly interested in random errors. These are normally distributed.

Gaussian distribution

When dealing with random noise, the probability of a value occurring can be described using a normal (Gaussian) distribution:

P(x)=1σ2πe(xμ)22σ2P(x) = \frac{1}{{\sigma \sqrt{2\pi}}}e^{\frac{{-(x - \mu)^2}}{{2\sigma^2}}}

Here, P(x)P(x) is the probability density function, with μ\mu being the mean value of the noise and σ\sigma being the standard deviation.

An example of a noise signal is shown in Figure 10 (the corresponding code is shown in a cell below). The mean of these values is 0. Repeating measurements therefore limits the influence of the noise because the mean contribution is 0:

M=i=1N(G+s)N=i=1NG+i=1NsN=i=1NGN=G\overline{M} = \frac{\sum_{i=1}^{N} (G + s)}{N} = \frac{\sum_{i=1}^{N} G + \sum_{i=1}^{N} s}{N} = \frac{\sum_{i=1}^{N} G}{N} = \overline{G}
Source
N = 1000
x = np.random.normal(0,5,N)

# Bereken van gemiddelde waarde en standaard deviatie
av_x = np.array([])
std_x = np.array([])
for i in range(1,len(x)-1):
    av_x = np.append(av_x,np.mean(x[:i]))
    std_x = np.append(std_x,np.std(x[:i],ddof=1))

# Plotten van de waarden als functie van N
plt.figure()
plt.plot(x,'k.',markersize=1)
plt.xlabel('N')
plt.ylabel('')
plt.xlim(0,N)
plt.savefig("Figures/noise.png",dpi=300)
plt.show()


plt.figure()
plt.plot(av_x,'k.',ms=1)
plt.xlabel('N')
plt.ylabel('average of x as function of N')
plt.xlim(0,N)
plt.savefig("Figures/noise_average.png", dpi=300)
plt.show()

plt.figure()
plt.plot(std_x,'k.',ms=1)
plt.xlabel('N')
plt.ylabel('standard deviation of x as function of N')
plt.xlim(0,N)
plt.savefig("Figures/noise_sigma.png",dpi=300)
plt.show()
Random noise, observe that outliers exist but are not frequent.

Figure 10:Random noise, observe that outliers exist but are not frequent.

The average value of noise is increasingly well defined with repeated measurements.

Figure 11:The average value of noise is increasingly well defined with repeated measurements.

The standard deviation becomes increasingly well defined with repeated measurements.

Figure 12:The standard deviation becomes increasingly well defined with repeated measurements.

We must be careful here, as Figure 13 shows that a histogram of four repeated measurements of noise always gives a slightly different picture. Each histogram consists of 1000 repeated measurements. So there is even an uncertainty in the uncertainty (12N2)\left( \frac{1}{\sqrt{2N-2}}\right ). The exact way in which we report our values is elaborated in Measurement uncertainty and significant figures.

Even 1,000 repeated measurements (of noise) show differences.

Figure 13:Even 1,000 repeated measurements (of noise) show differences.

Source
import matplotlib.pyplot as plt
import numpy as np
from scipy.optimize import curve_fit 
from scipy.stats import norm, poisson
from ipywidgets import interact
import ipywidgets as widgets

Below you can ‘play’ with the mean value and the standard deviation to see how these influence the measurements.

Source
# Maken van 1000 random punten

def update(average_value,std_value):

    x = np.random.normal(average_value,std_value,1000)

    # Bereken van gemiddelde waarde en standaard deviatie
    av_x = np.array([])
    std_x = np.array([])
    for i in range(1,len(x)-1):
        av_x = np.append(av_x,np.mean(x[:i]))
        std_x = np.append(std_x,np.std(x[:i],ddof=1))

    # Plotten van de waarden als functie van N
    plt.clf()
    fig, axs = plt.subplots(1,3,figsize=(15, 5))
    axs[0].plot(x,'k.',markersize=1)
    axs[0].set_xlabel('N')
    axs[0].set_ylabel('')

    axs[1].plot(av_x,'k.',ms=1)
    axs[1].set_xlabel('N')
    axs[1].set_ylabel('average of x as function of N')

    axs[2].plot(std_x,'k.',ms=1)
    axs[2].set_xlabel('N')
    axs[2].set_ylabel('standard deviation of x as function of N')

    plt.show()

interact(update, average_value=widgets.FloatSlider(min=-3, max=3, step=.5, value=0),
         std_value=widgets.FloatSlider(min=0, max=10, step=1, value=1))
# we voeren hier een experiment met 1000 samples 100x uit. Als bovenstaande klopt, dan is de standaard deviatie in het gemiddelde van de verschillende experimenten gelijk aan de onzekerheid in een enkele dataset.


mean_values = np.array([])
N = 100
samples = 1000

for i in range(N):
    dataset = np.random.normal(1.00,0.5,samples) 
    mean_values = np.append(mean_values,np.mean(dataset))
    
print('The standard deviation in the mean of repeated experiments is: ', np.std(mean_values,ddof=1))
print('The uncertainty in a single dataset is: ', np.std(dataset,ddof=1)/np.sqrt(samples))

Poisson distribution

A second probability distribution we introduce here is the Poisson distribution. Unlike the normal distribution, the Poisson distribution is discrete. It is used to count independent events within a certain time interval, where the events themselves occur randomly. Examples of this are radioactive decay, the number of photons that fall on a detector, etc.

The probability of kk events within a certain time with an average of λ\lambda is given by:

P(X=k)=λkeλk!.P(X = k) = \frac{\lambda^k e^{-\lambda}}{k!}.

The standard deviation in a Poisson distribution is equal to the square root of the mean (σ=λ\sigma = \sqrt{\lambda}).

Both the shape and the function are somewhat similar to those of the Gaussian distribution. However, there are clear differences, particularly for small values of λ\lambda. Furthermore, the number of events is always at least 0, whereas in a Gaussian distribution, the expected value can also be less than 0.

Uniform distribution

When you roll a die, the probability of rolling a 1 is the same as rolling a 6. In other words, the probability for any random number is uniformly (discreetly) distributed. Now suppose we are dealing with a continuous, uniform probability distribution, then the probability density function applies:

P(x)={1ba,if a<x<b0,elsewhereP(x)= \begin{cases} \frac{1}{b-a},& \text{if } a<x<b\\ 0, & \text{elsewhere} \end{cases}

The probability that a point lies between the values XX and X+dXX+dX (if XX lies between aa and bb!) is then given by:

p(X<x<X+dX)=XX+dX1badxp(X<x<X+dX) = \int_{X}^{X+dX}\frac{1}{b-a}dx

The expected value is simply being calculated by:

μ=a+b2\mu = \frac{a+b}{2}

and its standard deviation by:

σ=(ba)212\sigma = \sqrt{\frac{(b-a)^2}{12}}

Monte Carlo simulation

Such a uniform distribution is useful in Monte Carlo simulations, for example. In such a simulation, a large number of random points are generated and then examined to see where they end up. For an integral that cannot be solved analytically, you can still calculate the surface area:

abf(x)dx=NNtotaal(ba)(ymaxymin)\int_{a}^{b} f(x) dx = \frac{N}{N_{totaal}} \cdot (b-a) \cdot (y_{max} - y_{min})

Here, yminy_{min} and ymaxy_{max} are the vertical limits you choose for creating your random points. Of course, these must cover the entire graph!

An example of a Monte Carlo simulation is given in Figure 15, in which a simple integral is calculated by determining whether y<x2y<x^2 applies for 10,000 points. The integral on the domain [0,5] is then equal to the number of points that satisfy this condition divided by the total number of points created times 5 times 25. In such a Monte Carlo simulation (which is a counting problem), the uncertainty scales with 1N\frac{1}{\sqrt{N}}, where NN is the number of points that satisfy the condition (so choose the vertical boundaries optimally!).

An example of a Monte Carlo simulation for calculating an integral using a uniform distribution of random points.

Figure 15:An example of a Monte Carlo simulation for calculating an integral using a uniform distribution of random points.

Chauvenet’s criterium

Repeated measurements lead to a better average. However, in repeated measurements, certain values can deviate significantly from the average. It can be tempting to simply write off a measurement point that deviates significantly from the rest as a measurement error. However, this quickly becomes data manipulation, which is not the intention. You can apply Chauvenet’s criterion to see if the measurement point can be removed. Chauvenet’s criterion is a rule of thumb (there are other, more complicated methods for determining whether you can remove data points, but we will not discuss them here). Chauvenet’s criterion states that a measurement may be removed from the dataset if the probability of this is less than 12N\frac{1}{2N} or P(X)<12NP(X)<\frac{1}{2N}.

In more detail, this means that you first calculate the mean and standard deviation of your data, including the suspicious point. You can then omit a point if it satisfies the following inequality:

NPout<0.5N\cdot P_{out} < 0.5

where

Pout=2Erf(xout,x,σ)P_{out}=2\text{Erf}(x_{out},\overline{x},\sigma)

Here, erf is the error function, the integral of the normal distribution. The result of this integral cannot be calculated algebraically. You can calculate the value for the error function at https://www.danielsoper.com/statcalc/calculator.aspx?id=53. Below, we explain how to do this in Python.

If you use Chauvenet’s criterion to exclude an outlier, you must always mention this in your report! In addition, you must recalculate the mean and standard deviation after removing the suspect point. After all, this point has a significant effect on your dataset.

Exercise 4 (Outlier)

Which measurement from exercise 3 series 2 is suspicious? Use Chauvenet’s criterion to see if you can exclude this measurement.

Solution to Exercise 4

Pout=2Erf(x=19,x=25.4,σ=4.0)=20.05479929P_{out} = 2\cdot \text{Erf}(x = 19,\overline{x} = 25.4,\sigma = 4.0) = 2 \cdot 0.05479929

NPout=0.5479929>0.5N\cdot P_{out} = 0.5479929 > 0.5. We can not discard the measurement.

Error function(s)

There are two kinds of error functions, the erf(x)\text{erf}(x) and the Erf (xout,x,σ)\text{Erf} \space (x_{out},\overline{x},\sigma) (also called the cdf function). These are defined as:

erf(x)=2π0xet2dtErf (x,x,σx)=12[1+erf(xx2σx)]\begin{align*} \text{erf}(x) &= \frac{2}{\sqrt{\pi}} \int_0^x e^{-t^2} dt \\ \text{Erf} \space (x, \overline{x}, \sigma_x) &= \frac{1}{2} \left[1 + \text{erf}\left(\frac{x - \overline{x}}{\sqrt{2}\sigma_x}\right)\right] \end{align*}

A plot of both functions is given in Figuur 16

2 plots, one with \text{erf}(x) (left) and one with \text{Erf}(x_{out},\overline{x},\sigma) (right), \overline{x} = 10 and \sigma = 5.

Figure 16:2 plots, one with erf(x)\text{erf}(x) (left) and one with Erf(xout,x,σ)\text{Erf}(x_{out},\overline{x},\sigma) (right), x=10\overline{x} = 10 and σ=5\sigma = 5.

Both functions can be found in the scipy.special.erf and scipy.stats.norm.cdf functions. When using the Erf or scipy.stats.norm.cdf function (or the site), keep in mind that when investigating an upward outlier, the functions will all return a value above 0.5. This means that you must do Pout_new=1PoutP_{out\_new} = 1 - P_{out}. The final code should therefore be something like this:

from scipy.stats import norm

#P is the dataset (a numpy array)
x_out = np.max(P) #In this case, could also have been other outliers
x_mean = np.mean(P)
x_std = np.std(P,ddof=1)

#Use the Erf function
Q = norm.cdf(x_out,x_mean,x_std)
#You could have also defined the Erf on your own

#Check if it is a high 'outlier'
if Q > 0.5:
    Q = (1-Q)

#Use Chauvenets criterion
C =  2 * len(P) * Q

if C < 0.5:
    print('The value can be discarded.')
else:
    print('The value cannot be discarded.')

Measurement uncertainty and significant figures

An important rule regarding significant figures is that you must first determine the number of decimal places in your uncertainty. If you have fewer than 104 measurement points, the uncertainty should be expressed with one significant digit. The significance of your result is then adjusted so that its last digit corresponds to the digit of the uncertainty. You can use powers of 10 or prefixes to clearly represent the number, see table below.

There is another important point regarding rounding. If you were to round all fives up, you would introduce a systematic error; you always round up. The agreement is that if the number before the 5 is even, you round down (33.4533.433.45 \rightarrow 33.4), and if the number before the 5 is odd, you round up (33.5533.633.55 \rightarrow 33.6). In addition, in some fields it is good practice not to round down the uncertainty, as this prevents underestimating the uncertainty. However, we do not take this into account in physics practicals.

Table: Powers of 10, including their symbols.

power of 1010-1210-910-610-310-210-11011021031061091012
prefoxpiconanomicromillicentidecidecahectokilomegagigatera
symbolpnμ\mumcddahkMGT

For additional information about significant figures, you can watch this video.

Error propagation


You often apply a calculation to your raw data to arrive at an answer to your research question. A small deviation in your measurement can have major consequences for your final answer. That is why it is important to take the impact of uncertainties into account. There are two methods for calculating errors: the functional approach and the calculus approach. The former is more intuitive, but the latter is slightly easier to calculate.

In the theory below, we assume that we apply a function ZZ to our empirically determined value xx, whose mean is x\overline{x} with an uncertainty u(x)u(x).

Functional approach

With the functional approach, you look at the difference when you evaluate the function at the point that is one uncertainty away from your measuring point. In formula form, this becomes:

u(Z)=Z(x+u(x))Z(xu(x))2u(Z) = \frac{Z(\overline{x}+u(x)) - Z(\overline{x} - u(x))}{2}

In many cases, symmetry applies, which means that the above equation can also be interpreted as:

u(Z)=Z(x+u(x))Z(x)u(Z) = Z(\overline{x}+u(x)) - Z(\overline{x})

The functional approach is very useful for calculations that you need to repeat. In Python, you first define the function and then calculate the outcome for the variables + uncertainty. See the code below for the example given. This saves you a lot of time and calculations. However, when setting up a new method, the calculus approach gives a better picture of the magnitude of the uncertainties. You can use the calculus approach to dimension your experiment.

# Functional approach in calculation uncertainty of circumference of a circle
import numpy as np
def omtrek(x,a):
    return 2*np.pi*(x+a)
    
r = 2.0
ur = 0.1

u_omtrek = (omtrek(r,ur)-omtrek(r,-ur))/2
print(u_omtrek)

Calculus approach

In the calculus method, you use partial derivatives to linearize the effect of an error:

u(Z)=Zxu(x)u(Z) = |\frac{\partial Z}{\partial x}|u(x)

A consequence of the linear approach to the error is that this method becomes less accurate as the error increases or the function exhibits strongly non-linear behavior.

Multiple variables

If your result is a function of multiple independent variables, you add the errors quadratically:

u(f(x1,x2,,xn))2=i=1n(f(x)xiu(xi))2u(f(x_1,x_2,\dotsc,x_n))^2 = \sum_{i=1}^n \left(\frac{\partial f(\vec{x})}{\partial x_i}u(x_i)\right)^2

Using the calculus method, it can be deduced that the uncertainty u(f)u(f) applies to a function f(y,x)=cynxmf(y,x)=cy^nx^m:

(u(f)f)2=(u(c)c)2+n2(u(y)y)2+m2(u(x)x)2\left(\frac{u(f)}{f}\right)^2 = \left(\frac{u(c)}{c}\right)^2+n^2\left(\frac{u(y)}{y}\right)^2+m^2\left(\frac{u(x)}{x}\right)^2

Eric is weighing a box. The mass is (56 ± 2) g. The box’s sides are (3.0 ± 0.1) cm.

  1. Calculate the gravity working on the box.

  2. Calculate the volume of the box.

  3. Calculate the density of the box.

Solution to Exercise 5
  1. (0.55±0.02)(0.55 \pm 0.02) N

  2. (27±3)(27 \pm 3) cm3^3

  3. (2.1±0.2)(2.1 \pm 0.2) g/cm3^3

Please note that if you have two values A and B that are close to each other and you subtract them from each other (A-B), your error may well be much greater than the difference between those two values. In such cases, you will need to look for alternative measurement methods that yield a smaller relative uncertainty. See below for an example for inspiration.

The table below gives measurements of the voltage of and current through a lamp.

Table: Measurements of a lamp.

UU(V)u(U)u(U)(V)II(mA)u(I)u(I)(mA)
6.00.20.250.1
1.  Determine the power that the lamp absorbs.

2.  Determine the resistance of the lamp.

3.  If you could measure either the voltage or the current more accurately, which would you choose and why?
Solution to Exercise 6
  1. P=(1.5±0.6103)P = (1.5 \pm 0.6\cdot 10^{-3}) W

  2. R=(2.4±1104)ΩR = (2.4 \pm 1\cdot 10^4) \Omega

  3. The current, because it has the biggest relative uncertainty.

The table below gives values and uncertainties for variables AA, BB, and CC. Calculate the value and uncertainties of ZZ for the cases given below.

Table: Three variables and their uncertainties.

AAu(A)u(A)BBu(B)u(B)CCu(C)u(C)
5.00.1500210.1
  1. Z=ABC2Z = \frac{A}{BC^2}

  2. Z=ABC4Z = \frac{A}{BC^4}

  3. Z=CABZ = C\sqrt{AB}

Solution to Exercise 7
  1. Z=0.010±0.002Z = 0.010 \pm 0.002

  2. Z=0.010±0.004Z = 0.010 \pm 0.004

  3. Z=50±5Z = 50 \pm 5

Dimensioning

One advantage of the Calculus method over the Functional Approach is that it allows you to dimension your experiment: based on predefined criteria, you can determine how large the experiment should be, what characteristics it should have, and where most of the time and attention should be focused to ensure the experiment meets the set criteria. The easiest way to illustrate this is with an example.

Fitting

We often measure a quantity as a function of another quantity—for example, the extension of a spring as a function of the applied load, or the period of a pendulum as a function of its length. The purpose of such measurements can vary. For example, we may ask ourselves: How (according to which functional relationship) does the elongation depend on the load? Or: What is the spring constant of the spring? We then assume a certain relationship and use that relationship to determine the values of parameters. In the first case, we refer to this as modeling, and in the second case, as adjusting or “fitting.” In statistics, the second case is known as a regression problem. We will discuss this in more detail below.

Fitting is a procedure that attempts to find a mathematical relationship in a number of (measurement) points. We are then looking for a relationship F(x)F(x) that describes the measurement points M(x)M(x) in such a way that:

F(x)M(x)0F(x) - M(x)\approx 0

First, you need to choose a type of relationship. Examples include a linear fit, a polynomial, sine, etc. In the fitting procedure itself, the parameters of this relationship are chosen so that they best match the data. For example, if a second-order polynomial is being fitted, you look for the combination of aa, bb, and cc that ensures that the curve a+bx+cx2a + bx + cx^2 fits your measurement points as closely as possible.

A commonly used method for determining the goodness of a fit is the least-squares method. In this method, the sum of the squared distances from the measurement points to the fit is minimized. To do this, we first define the distance between the measurement point and the fit:

Ri=MiFiR_i = M_i - F_i

This distance is also referred to as the residue, which we will discuss in more detail later. The total sum of the absolute distances must be as small as possible:

χ2=Ri2\chi^2=\sum R_i^2
The idea of a least-square method is that the area is minimized.

Figure 19:The idea of a least-square method is that the area is minimized.

You can see when χ2\chi^2 is as small as possible by playing with the sliders below.

In the above case, we assume that the value of the independent variable has been determined with sufficient accuracy and precision. There are other techniques that take into account the deviation in the dependent variable. We can also look again at the influence of measurement uncertainty in determining the best fit.

Weighted fit

Just as a weighted average takes into account the uncertainty in the measurement, you can use a weighted fit for a function fit. This allows you to take into account the uncertainty in the dependent variable (there is also a technique that takes into account the uncertainty in both the independent and dependent variables, but we will not discuss that here).

For a weighted fit, the smallest value for χ2\chi^2 is considered, taking the uncertainty into account:

χ2=(MiFi)2u(Mi)2\chi^2 = \sum \frac{(M_i-F_i)^2 }{u(M_i)^2}

Other fit types

In a least-squares fit, we attempt to minimize the squared residuals. This method works particularly well when the uncertainty is primarily in the dependent variable. In such cases, we can control the independent variable or reduce its uncertainty enough that it becomes negligible compared to the uncertainty in the dependent variable.

However, the least-squares method is not the only fitting approach. There is also, for example, the ‘orthogonal distance regression’ method, also called smallest distance method. This method is visualized in Figure 20. We will not provide the further mathematical elaboration here, but how the method can be implemented can be found in source.

Another fitting method is ODR, which minimizes the distance to the fitting line.

Figure 20:Another fitting method is ODR, which minimizes the distance to the fitting line.

Residual analysis

In one of the previous sections, we discussed that a physical measurement (M(x)M(x)) can be described as the sum of the physical value (G(x)G(x)) + noise (ss). A function fit (F(x)F(x)) is performed based on the measurements. To check that we have a good fit, we need to look at the noise. We would get this if we subtract the fit function from the measurement:

R=M(x)F(x)=?sR = M(x) - F(x) \stackrel{?}{=} s

The initial analysis is performed by plotting the noise ss as a function of the independent variable xx. If there is a pattern in this, for example a rising line, a sinusoidal signal, or all noise points above 0, see Figure 21, then there is a good chance that a better function F(x)F(x) can be found that describes the physical value G(x)G(x).

(a) M(x) = 2x + 0.05 , (b) M(x) = 2x + 0.1x en (c) M(x) = 2x + 0.05sin(3x).
Each measurement contains a ‘hidden’ signal that is visible when analyzing the residuals. In all figures a line F(x) = 2x was fitted.

Figure 21:(a) M(x)=2x+0.05M(x) = 2x + 0.05 , (b) M(x)=2x+0.1xM(x) = 2x + 0.1x en (c)M(x)=2x+0.05sin(3x)(c) M(x) = 2x + 0.05sin(3x). Each measurement contains a ‘hidden’ signal that is visible when analyzing the residuals. In all figures a line F(x)=2xF(x) = 2x was fitted.

The second analysis of the residue is based on a histogram. If, based on the experiment, you expect the noise to be normally distributed, then the histogram will be a normally distributed function. You can also apply a function fit to this noise signal, whereby we expect the mean to be 0 and the standard deviation to be determinable.

Linearization

When experimenting, the goal is often to discover the relationship between two variables. In many cases, this relationship is not linear, for example between the swing time and length of a pendulum. In such cases, it is useful to linearize the graphs. Firstly, this makes it easier to see deviations, and secondly, it also makes fitting easier.

Agreement analysis

One of the most important reasons for determining uncertainty is that you want to compare results with each other or with theoretical predictions systematically and quantitatively, and thus determine the extent to which the values differ from each other. The question then is: ‘To what extent do the empirically found values correspond with ...’.

Suppose we want to compare two values aa and bb, each with their own uncertainty u(a)u(a) and u(b)u(b). Then we first want to look at the difference between these two values: v=abv = a- b. Based on the calculus approach, the uncertainty in vv is given by u(v)=u(a)2+u(b)2u(v) = \sqrt{u(a)^2 + u(b)^2}. The agreement now is that two values are inconsistent with each other (in a scientific sense, they do not correspond sufficiently with each other) if the following applies:

v=ab>2u(a)2+u(b)2=2u(v)\lvert v \rvert = \lvert a - b \rvert > 2\sqrt{u(a)^2 + u(b)^2} = 2u(v)

When determining physical constants, the uncertainty is often so small that it is negligible compared to other uncertainties. Please note! You could argue that if your measurement uncertainty is large enough, the values will never be contradictory. However, when the uncertainty is relatively large compared to the determined value, the values found have little scientific value.

Great examples of ugly graphs

There are many ways in which you can present your data poorly. There are only a few ways in which you can do it well. The most important thing when creating a graph is that it is clear and that it is obvious to the reader what they should be looking at.

Figure 24 is a good example of a bad graph. First of all, the trend is not visible. There is one point that is well above the others, but are the values for r>11r>11 equal to 0 or not? In addition, there are far too many numbers (ticks) on the horizontal axis. The scale for the horizontal axis is also poorly chosen. Furthermore, we are missing what is actually presented on the horizontal and vertical axes.

A great example of an ugly graph

Figure 24:A great example of an ugly graph

Figure 25 presents the same data. The differences may be clear, the data are displayed on a log-log scale, and a trend line shows the relationship between force and distance. The number of ticks is limited. The graph could be further improved by including the measurement uncertainty.

An improved version of the graph

Figure 25:An improved version of the graph

Further reading

Some external sources on the use of data and measurement uncertainty:
Guide to the expression of uncertainty in measurement
Liegen met cijfers
Het bestverkochte boek ooit

Exercises

The values of aa and xx are given in the table below.

au(a)u(a)xu(x)u(x)
51085\cdot10^{-8}11091\cdot10^{-9}51035\cdot10^{-3}11031\cdot10^{-3}
  1. Determine the value and uncertainty of F=ax4F = a \cdot x^{-4}.

  2. Perform the same exercise as above, but use u(a)=1109u(a) = 1 \cdot 10^{-9} en u(x)=11010u(x) = 1 \cdot 10^{-10}. What do you notice?

  3. Keep u(a)u(a) a constant, and use u(x)=1103u(x) = 1\cdot 10^{-3} and u(x)=1104u(x) = 1\cdot 10^{4}. What do you notice?

  4. Compare your answers to (2) and (3). Why does the error in FF scale linearly with the error in aa, but not with xx?

Solution to Exercise 8
  1. F=(5±6)101F = (5 \pm 6) \cdot 10^1

  2. F=(50.0±1.6)F = (50.0 \pm 1.6)

Derive equation (26).

Solution to Exercise 9

First use the calculus method, and then divide by ff.

A distance ss is measured as the difference between two distances pp and qq. The positions of pp and qq are: p=(30.0±0.9)p = (30.0\pm0.9) km and q=(10.0±0.1)q = (10.0\pm0.1) km. Calculate the distance ss and the corresponding uncertainty u(s)u(s). Write the result down using the correct notation.

Solution to Exercise 10

s=(20.0±0.9)kms = (20.0 \pm 0.9) \text{km}

Consider a beam with length L=(7.5±0.1)L=(7.5\pm0.1) m, width B=(12.5±0.2)B=(12.5\pm0.2) cm en height H=(15.0±0.3)H=(15.0\pm0.3) cm. The area AA is given by BHB \cdot H. Determine the uncertainties u(A)u(A) and u(V)u(V).

Solution to Exercise 11

u(A)=(u(B)B)2+(u(H)H)2BH=(0.212.5)2+(0.315.0)212.515=5 cm2u(A) = \sqrt{(\frac{u(B)}{B})}^2+{(\frac{u(H)}{H})^2} \cdot B \cdot H= \sqrt{(\frac{0.2}{12.5})^2+{(\frac{0.3}{15.0})}^2} \cdot 12.5 \cdot 15 = 5 \space \text{cm}^2
u(V)=(u(B)B)2+(u(H)H)2+(u(L)L)2BHL=0.004 m3u(V) = \sqrt{{\left(\frac{u(B)}{B}\right)}^2+{\left(\frac{u(H)}{H}\right)}^2+{\left(\frac{u(L)}{L}\right)}^2} \cdot B \cdot H \cdot L= 0.004 \space \text{m}^3

The gravitational acceleration gg is determined using a pendulum. The period is T=(1.60±0.03)T = (1.60\pm0.03) s and the length of the pendulum is L=(64.0±0.8)L = (64.0\pm0.8) cm.

  1. Give the relation between the period and the length of the pendulum.

  2. Use this relation to derive a formula for the gravitational acceleration gg.

  3. Give the formula for the uncertainty u(g)u(g).

  4. Calculate gg and u(g)u(g) and write the results down using the correct notation.

  5. Which variable has the biggest influence of the uncertainty?

Solution to Exercise 12
  1. T=2πLgT = 2 \pi \sqrt{\frac{L}{g}}

  2. g=4π2LT2g = \frac{4 \pi ^2 L}{T^2}

  3. (u(g)g)2=(u(L)L)2+4(u(T)T)2\left(\frac{u(g)}{g}\right)^2 = \left(\frac{u(L)}{L}\right)^2 + 4 \left(\frac{u(T)}{T}\right)^2

  4. g=9.8696 m/s2g = 9.8696 \space \text{m/s}^2
    u(g)=0.39 m/s2u(g) = 0.39 \space \text{m/s}^2
    dus g=(9.9 ±0.4)m/s2g = (9.9 \space \pm 0.4)\text{m/s}^2

  5. TT, factor 4x as big on the calculation of u(g)u(g). 10x as big in the more precise calculation.

Variable GG is dependent on the measured variables xx and yy, and their relation is G(x,y)=12xy3+5x2yG(x,y)=\frac{1}{2} x y^{3} + 5 x^{2} y. The uncertainties in xx and yy are u(x)u(x) and u(y)u(y), respectively. Determine the equation for the uncertainty u(G)u(G).

Solution to Exercise 13

G(x,y)=12xy3+5x2y=G1+G2G(x,y)=\frac{1}{2} x y^{3} + 5 x^{2} y = G_1 + G_2
u(G)=u(G1)2+u(G2)2u(G) = \sqrt{u(G_1)^2+u(G_2)^2}
(u(G1)G1)2=(u(x)x)2+9(u(y)y)2\left({\frac{u(G_1)}{G_1}}\right)^2 = \left({\frac{u(x)}{x}}\right)^2 + 9 \left({\frac{u(y)}{y}}\right)^2
(u(G2)G2)2=4(u(x)x)2+(u(y)y)2\left({\frac{u(G_2)}{G_2}}\right)^2 = 4 \left(\frac{u(x)}{x}\right)^2 + \left({\frac{u(y)}{y}}\right)^2

Consider a sphere with radius R=(3.02±0.06)R=(3.02 \pm 0.06) m. Determine the surface area AA and the volume VV with the corresponding (relative) uncertainties.

Solution to Exercise 14

A=4πr2=114.61 m2A = 4 \pi r ^2 = 114.61 \space \text{m}^2
u(A)=4(u(r)r)2A=5 m2u(A) = \sqrt{4 \left(\frac{u(r)}{r}\right)^2} \cdot A = 5 \space \text{m}^2
A=(115±5)A = (115 \pm 5) m2^2 V=43πr3=115.37 m3V = \frac{4}{3} \pi r ^3 = 115.37\space \text{m}^3
u(V)=9(u(r)r)2V=7 m3u(V) = \sqrt{9 (\frac{u(r)}{r})^2} \cdot V = 7 \space \text{m}^3
V=(115±7) m3V = (115 \pm 7)\space \text{m}^3

Consider f(x)=2sinxf(x)=2\sin{x}, with xx a measured quantity with uncertainty u(x)u(x). Derive an equation for the uncertainty u(f)u(f).

Solution to Exercise 15

u(f)=fxu(x)=2sin(x)xu(x)=2cos(x)u(x)u(f) = |\frac{\partial f}{\partial x}| \cdot u(x) = |\frac{\partial 2\sin(x)}{\partial x}| \cdot u(x) = 2|\cos(x)| \cdot u(x)

How can you linearize the relations (1-4) below, such that they can be plotted as a straight line y=mx+cy = mx + c? Give the expression for the slope mm, and the intersection cc.

  1. V=aU2V = aU^2

  2. V=aUV = a\sqrt{U}

  3. V=aexp(bU)V = a \exp{(-bU)}

  4. 1U+1V=1a\frac{1}{U} + \frac{1}{V} = \frac{1}{a}

Solution to Exercise 16
  1. yy-axis: V\sqrt{V}, xx-axis: UU. m: a\sqrt{a}, c: 0

  2. yy-axis: V2V^2, xx-axis: UU. m: a2a^2, c: 0

  3. yy-axis: lnV\ln{V}, xx-axis: UU. m: b-b, c: 0

  4. yy-axis: 1V\frac{1}{V}, xx-axis: 1U\frac{1}{U}. m: -1, c: 1a\frac{1}{a}

  5. 1U+1V=1a\frac{1}{U} + \frac{1}{V} = \frac{1}{a}