Statistics of Repeated Readings
You measure a nominal standard resistor eight times and get eight slightly different numbers, one of them clearly off. What do you report: the mean, the median, the mean without the odd one? How many digits are justified, and how wide is the interval with eight readings rather than eighty? This lesson applies the statistics of Probability to the readings an engineer actually takes: few of them, possibly with an outlier, and possibly not independent.
The three numbers of a sample
For readings :
- estimates the value the instrument tends to.
- , the experimental standard deviation, describes one reading: a new single reading will scatter by about . The divisor (Bessel's correction) makes unbiased for the variance; NumPy needs
ddof=1for it. - , the experimental standard deviation of the mean, describes the mean. It is the Type A standard uncertainty of in the GUM.
Which one you need depends on the question. "What is this resistor's value?" uses . "How far might the next production reading fall from the mean?" uses .
Few readings: the t-distribution
With small , itself is uncertain, so an interval of covers less than . The fix is Student's t-distribution with degrees of freedom: the interval of the mean is
| 3 | 5 | 8 | 10 | 20 | 50 | ||
|---|---|---|---|---|---|---|---|
| 4.30 | 2.78 | 2.36 | 2.26 | 2.09 | 2.01 | 1.96 |
Three readings need a factor of , not . Five to ten readings is the usual engineering compromise. (The Statistics course covers the distribution itself.)
Outliers: reject only for a reason
A reading far from the rest is first a question for the notebook: was the range changed, the probe touched, the lead moved? If a cause is found, the reading is a gross error and is struck out with the reason written next to it. If no cause is found, a statistical test can flag it. Grubbs' test compares the largest deviation with the spread:
and rejects the extreme point when exceeds a critical value that depends on and the significance level ( for at , two-sided). Apply it once, record that you did, and never iterate until the data look tidy. The old "Chauvenet's criterion" is still found in textbooks; it rejects more readily and is not recommended.
Independence matters
assumes independent readings. Readings taken faster than the instrument's noise changes (a DMM sampling every during a thermal drift, or noise in an amplifier) are correlated, and is then too optimistic. A quick check is the lag-1 autocorrelation of the readings; for an AR(1)-like process an effective number of independent readings is
When is large, space the readings further apart, or use the Allan deviation to see at which averaging time drift takes over.
Worked example: eight readings of a standard resistor
Given: readings in ohms: , , , , , , , . The notebook records nothing unusual for the last one.
Find: whether to reject the last reading, then the mean and its interval.
Solve: with all eight readings, and . The farthest point is :
so Grubbs flags it. Without it (), , , , :
Check: the interval is a few hundredths of an ohm, consistent with the spread of the seven readings ( from smallest to largest); the rejected reading is off, fifteen times the half-width. Report the rejection and the test in the notebook. This is only the Type A part; the meter's calibration still has to be added (GUM Uncertainty Budgets).
import numpy as np
from scipy import stats
x = np.array([1000.12, 1000.15, 1000.09, 1000.14, 1000.11, 1000.13, 1000.10, 1000.42])
def grubbs_critical(n, alpha=0.05):
t = stats.t.ppf(1 - alpha / (2 * n), n - 2)
return (n - 1) / np.sqrt(n) * np.sqrt(t**2 / (n - 2 + t**2))
n = len(x)
G = float(np.max(np.abs(x - x.mean())) / x.std(ddof=1))
print(f"all {n}: mean {x.mean():.4f}, s {x.std(ddof=1):.4f}, G = {G:.2f}, G_crit = {grubbs_critical(n):.2f}")
y = np.delete(x, np.argmax(np.abs(x - x.mean())))
m, s = float(y.mean()), float(y.std(ddof=1))
u = s / np.sqrt(len(y))
t = stats.t.ppf(0.975, len(y) - 1)
print(f"kept {len(y)}: mean {m:.4f} ohm, s {s:.4f}, s/sqrt(n) {u:.4f}, t = {t:.3f}")
print(f"95 % interval: {m:.3f} +/- {t * u:.3f} ohm")
# Correlated readings: a slow drift plus noise, 50 readings
rng = np.random.default_rng(3)
e = np.zeros(50)
for i in range(1, 50):
e[i] = 0.9 * e[i - 1] + 0.01 * rng.standard_normal()
r1 = float(np.corrcoef(e[:-1], e[1:])[0, 1])
n_eff = 50 * (1 - r1) / (1 + r1)
print(f"drifting readings: r1 = {r1:.2f}, n_eff = {n_eff:.1f} of 50, "
f"s/sqrt(n) understates u by a factor {np.sqrt(50 / n_eff):.1f}")all 8: mean 1000.1575, s 0.1079, G = 2.43, G_crit = 2.13
kept 7: mean 1000.1200 ohm, s 0.0216, s/sqrt(n) 0.0082, t = 2.447
95 % interval: 1000.120 +/- 0.020 ohm
drifting readings: r1 = 0.75, n_eff = 7.0 of 50, s/sqrt(n) understates u by a factor 2.7
Guided lab: watching the mean settle
Hand calculation. The lab's "spread" is the standard deviation of the readings. Ten readings with typically span about , so the school "half the range" rule gives about , while is about .
Simulation. The lab takes one reading a second on a vernier. With these settings the ten readings run from to (mean ); the half-range rule ends at and the mean-deviation rule at . From the same ten numbers, and . Both school rules describe the scatter of one reading; neither is the uncertainty of the mean. Change the data set and watch how much the half range jumps around with a single extreme reading.
What you would measure. Take 20 readings of a , resistor with a 5½-digit DMM, one every 5 s. Expect of one or two counts ( to ), a mean within the resistor's tolerance, and near zero. Then hold the resistor in your fingers between readings: the warming drift makes approach 1 and the "uncertainty of the mean" meaningless.
Hazards and safe setup. None beyond the meter itself: the ohms function drives about .
Pitfalls
- Using
np.stdwithoutddof=1(population formula) for a handful of readings. - Quoting as a interval for three readings.
- Deleting inconvenient readings without a recorded reason or a single, declared test.
- Taking hundreds of fast readings of a drifting quantity and claiming a tiny .
Practice
- Five readings have . Give the standard uncertainty of the mean and the half-width.
- Readings of : how many independent readings are 40 correlated ones worth?
Answer
- ; half-width .
- .
Test yourself
The Type A standard uncertainty of the mean of readings is
- the range divided by 2
Why use the t-factor instead of 1.96 for five readings?
- The readings are not normal
- is itself uncertain with few readings
- It makes the interval smaller
- The GUM forbids 1.96
A reading is far from the others and the notebook records that the probe slipped. You should
- keep it, data are data
- strike it out with the reason recorded
- run Grubbs' test repeatedly
- average it in with a lower weight
Readings with lag-1 autocorrelation have
- more information than independent ones
- about one ninth as many effective readings
- no effect on the uncertainty
- a smaller , so a smaller uncertainty