A4 · Lesson 48 · Statistics of measurements
How sure are you of that average?
You measure a reference voltage 25 times: the readings scatter by a few millivolts around 2.500 V. The average is your best estimate, but how good is it? Ten times as many readings won't make each one less noisy, but it will pin down the average about three times better. Reporting a measurement properly means giving a value with an uncertainty, and that uncertainty comes from a few short formulas that this lesson puts into code.
Predict
The readings scatter with a standard deviation of 4 mV. You average 100 of them. Roughly how uncertain is the average?
About 0.4 mV. The uncertainty of a mean of independent readings is the spread of one reading divided by , and . That's the standard error of the mean. Averaging more helps, but slowly: a hundred times more readings for ten times less uncertainty.
Name it
Spread and the uncertainty of a mean
For readings :
| Quantity | Formula | In NumPy |
|---|---|---|
| mean | x.mean() | |
| sample standard deviation | x.std(ddof=1) | |
| standard error of the mean | x.std(ddof=1) / np.sqrt(len(x)) |
ddof=1 gives the version; NumPy's default divides by .
For readings whose noise is roughly normal (bell-shaped), the true mean lies within about standard errors of in 95% of experiments: that's an approximate 95% confidence interval. With fewer than about 20 readings, a slightly larger multiplier from the distribution is more accurate (A11 covers it).
Histograms
counts, edges = np.histogram(x, bins=20) counts readings in equal bins. Looking at the histogram before trusting a mean and standard deviation catches two common problems: two groups mixed together (two humps) and outliers far from the rest.
Combining uncertainties
When a result is calculated from measured inputs, its uncertainty follows from theirs. For independent inputs, relative uncertainties of a product or quotient add in quadrature, each weighted by its power:
For a sum or difference, the absolute uncertainties add in quadrature: . Adding in quadrature is smaller than adding straight, because independent errors partly cancel; A1's worst-case sum is the pessimistic bound.
Combining measurements
Two measurements of the same thing with different uncertainties combine best as a weighted mean, each weighted by :
The better measurement counts for more, and the combination is better than either.
Worked example
25 readings of a reference have a mean of 2.5012 V and a sample standard deviation of 3.0 mV. Report the voltage with a 95% interval.
Show the solution
- The standard error.
- The 95% interval.
- Report it. V (95%).
- The small-sample correction. With 25 readings the -distribution multiplier would be 2.06 instead of 1.96, giving ±1.24 mV, a small correction.
Answer V, at 95% confidence.
Worked example
You measure 12.00 V ± 0.5% and 47.0 Ω ± 1% and compute . What is the uncertainty in ?
Show the solution
- The power.
- The relative uncertainty. is squared, so its 0.5% counts twice; combine in quadrature:
- The absolute uncertainty. 1.41% of 3.064 W:
- Compare with the worst case. The worst-case bound would be ; the quadrature value is what independent errors typically give.
Answer W, an uncertainty of 1.41%.
Check
The starter simulates n = 16 noisy readings. Set m, s (sample standard deviation), sem (standard error of the mean) and ci to the half-width of an approximate 95% interval, sem.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
The starter's readings are a mix of two groups. Set counts, edges with np.histogram(x, bins=30) and mode_center to the center of the bin with the most counts.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
You compute from V = 5 V (±0.5%) and R = 100 Ω (±5%), both independent. Set P and uP to its relative uncertainty in percent, combined in quadrature.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Two instruments measure the same voltage: x1 = 3.301 V ± 0.002 V and x2 = 3.305 V ± 0.001 V. Set xw to the weighted mean and sw to its uncertainty.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
The starter's 200 readings include a few glitches. Set m and s to their mean and sample standard deviation, then clean to an array of the readings within 3 s of m, n_removed to how many were dropped, and m_clean to the mean of clean.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Readings scatter with a standard deviation of 4 mV. How many must you average to bring the standard error of the mean down to 0.5 mV or less?
Explain why
Why does averaging 100 readings only make the result 10 times more precise, not 100 times?
The random errors in the readings partly cancel when you add them, but only partly: the spread of a sum of independent errors grows as , not . Dividing by to get the average leaves a spread of . So a hundred readings shrink the uncertainty by .
Practice
Keep practicing
8 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.