Skip to content
Tactiverge

Measurement uncertainty and error bars

Every measurement comes with uncertainty. Learn to estimate it from repeated measurements, report a mean with its standard error, and draw honest error bars.

Lesson 2 of 6 · 30 min · Self-paced · Free

A number without uncertainty is half a result

A robot needs to place a part in a slot that is 50.20 mm wide. You measure the part and get 50.11 mm. Will it fit? It depends on something the single number does not tell you: how sure are you? If your measurement could easily be off by 0.01 mm, the part fits. If it could be off by 0.2 mm, you do not know yet. Engineers therefore report measurements as a value and an uncertainty, such as 50.11 ± 0.01 mm, and they say what the ± means.

Two kinds of error

In measurement, "error" does not mean a mistake. It means the difference between what you measured and the true value.

  • Random error changes from one reading to the next: a slightly different grip on the calipers, electrical noise in a sensor, the exact moment you press a stopwatch. Readings scatter both above and below the true value.
  • Systematic error pushes every reading the same way: calipers that read 0.05 mm when closed, a scale that was never zeroed, a thermometer in direct sunlight. Readings can agree beautifully with each other and all be wrong.

Repeating a measurement and averaging helps with random error. It does nothing for systematic error. You only find systematic error by checking your instrument against a known reference, such as a gauge block or a calibration weight.

Repeated measurements

Here are six repeated measurements of the same bracket (made-up data for illustration):

50.12, 50.08, 50.15, 50.10, 50.06, 50.13 mm

The sample standard deviation s, from the previous lesson, describes how much a single reading scatters. But we are going to report the mean of six readings, and a mean is more reliable than any one reading, because random errors partly cancel when you average.

The standard error of the mean

How much would the mean itself wobble if you repeated the whole set of six measurements again and again? The answer is the standard error of the mean (SE):

SE = s / √n

The √n is the key idea. Averaging 4 readings halves the uncertainty of the mean compared with one reading; averaging 100 readings cuts it by a factor of 10. To halve your standard error you need four times as many measurements. Precision gets expensive.

import math
import statistics

# Made-up data for illustration: one bracket's length (mm), measured 6 times
lengths = [50.12, 50.08, 50.15, 50.10, 50.06, 50.13]

n = len(lengths)
mean = statistics.mean(lengths)
s = statistics.stdev(lengths)
se = s / math.sqrt(n)

print(f"n = {n}")
print(f"mean = {mean:.3f} mm")
print(f"s    = {s:.3f} mm")
print(f"SE   = {se:.3f} mm")
print(f"Result: {mean:.2f} ± {se:.2f} mm (mean ± SE, n = {n})")

Output:

n = 6
mean = 50.107 mm
s    = 0.033 mm
SE   = 0.014 mm
Result: 50.11 ± 0.01 mm (mean ± SE, n = 6)

Notice the rounding. The uncertainty is about 0.01 mm, so quoting the mean as 50.1067 mm would claim precision you do not have. A good rule: round the uncertainty to one or two significant figures, then round the value to the same decimal place.

Watching the standard error shrink

In a simulation we can choose the true value, which is impossible in a real experiment. Here every simulated reading is the true length, 50.00 mm, plus random noise with a standard deviation of 0.40 mm:

import math
import random
import statistics

random.seed(7)
TRUE_LENGTH = 50.00   # mm, known only because this is a simulation
NOISE = 0.40          # mm, standard deviation of each reading

for n in [4, 16, 64, 256]:
    readings = [random.gauss(TRUE_LENGTH, NOISE) for _ in range(n)]
    s = statistics.stdev(readings)
    se = s / math.sqrt(n)
    print(f"n = {n:3d}   mean = {statistics.mean(readings):.3f}   "
          f"s = {s:.3f}   SE = {se:.3f}")

Output:

n =   4   mean = 49.971   s = 0.156   SE = 0.078
n =  16   mean = 49.941   s = 0.390   SE = 0.097
n =  64   mean = 49.979   s = 0.390   SE = 0.049
n = 256   mean = 50.026   s = 0.424   SE = 0.026

Three things to notice:

  1. s does not shrink as n grows; it settles near the true noise, 0.40 mm. More data does not make individual readings less noisy.
  2. SE does shrink, roughly halving each time n quadruples. More data makes the mean more certain.
  3. With only 4 readings, s came out at 0.156 mm, far below the true 0.40 mm. With small samples, even the estimate of spread is unreliable, which is why the SE for n = 4 looks deceptively small.

The random.seed(7) line makes the "random" numbers the same every time you run the program, so you can check your output against this page.

Error bars and what they mean

On a plot, uncertainty is usually drawn as an error bar: a line through each point showing a range. The trouble is that error bars can mean several different things:

  • ±1 standard deviation: how much individual readings scatter.
  • ±1 standard error: how uncertain the mean is.
  • A 95% confidence interval: a range constructed so that, if you repeated the experiment many times, about 95% of such ranges would contain the true mean.

These can differ by a large factor. For our bracket, ±1 s is ±0.033 mm, but ±1 SE is ±0.014 mm. Always state which one you drew, and always state n.

For large samples, a 95% confidence interval is approximately the mean ± 2 SE. For small samples you need a larger multiplier taken from a table of the t-distribution; with n = 6 it is about 2.57. So a careful 95% interval for the bracket is 50.107 ± 2.57 × 0.0136, or roughly 50.07 to 50.14 mm. Now we can answer the opening question: even the top of that range leaves a gap below 50.20 mm, so the part fits, provided there is no systematic error in the calipers.

Recap

  • Report a measurement as a value, an uncertainty and an explanation of what the uncertainty means.
  • Random error scatters readings and is reduced by averaging; systematic error biases every reading and is found only by calibration.
  • The standard error of a mean is s / √n. Quadrupling the number of measurements halves it.
  • Error bars must be labelled: standard deviation, standard error or confidence interval, with n.
  • Round the value to match its uncertainty.

Knowledge check

Check your understanding

  1. 1. Ten readings have a sample standard deviation of 0.6 V. What is the standard error of their mean?
  2. 2. You want to halve the standard error of a mean you currently compute from 25 readings. Roughly how many readings do you need?
  3. 3. Every reading from a thermometer is 1.5 °C too high because it sits in sunlight. What will averaging many readings do?
  4. 4. A graph shows two means with error bars but does not say what the bars are. Why is this a problem?
  5. 5. In the simulation, why did the sample standard deviation stay near 0.4 mm as n increased, while the standard error shrank?

Go further

Measurement uncertainty and error bars — Computational Engineering — Tactiverge