TExcelTAD
Home › Electrical & Electronic Measurements › Statistics of Repeated Readings

Statistics of Repeated Readings

You measure a nominal 1 kΩ1\ \text{k}\Omega 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 nn readings x1,…,xnx_1, \dots, x_n:

xˉ=1n∑i=1nxi,s=1n−1∑i=1n(xi−xˉ)2,sxˉ=sn\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i, \qquad s = \sqrt{\frac{1}{n-1}\sum_{i=1}^{n} (x_i - \bar{x})^2}, \qquad s_{\bar{x}} = \frac{s}{\sqrt{n}}
  • xˉ\bar{x} estimates the value the instrument tends to.
  • ss, the experimental standard deviation, describes one reading: a new single reading will scatter by about ss. The divisor n−1n - 1 (Bessel's correction) makes s2s^2 unbiased for the variance; NumPy needs ddof=1 for it.
  • sxˉs_{\bar{x}}, the experimental standard deviation of the mean, describes the mean. It is the Type A standard uncertainty of xˉ\bar{x} in the GUM.

Which one you need depends on the question. "What is this resistor's value?" uses sxˉs_{\bar{x}}. "How far might the next production reading fall from the mean?" uses ss.

Few readings: the t-distribution

With small nn, ss itself is uncertain, so an interval of ±2sxˉ\pm 2 s_{\bar{x}} covers less than 95 %95\,\%. The fix is Student's t-distribution with ν=n−1\nu = n - 1 degrees of freedom: the 95 %95\,\% interval of the mean is

xˉ±t0.975, ν sn\bar{x} \pm t_{0.975,\,\nu}\, \frac{s}{\sqrt{n}}
nn 3 5 8 10 20 50 ∞\infty
t0.975, n−1t_{0.975,\,n-1} 4.30 2.78 2.36 2.26 2.09 2.01 1.96

Three readings need a factor of 4.34.3, not 22. 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:

G=max⁡i∣xi−xˉ∣sG = \frac{\max_i \lvert x_i - \bar{x} \rvert}{s}

and rejects the extreme point when GG exceeds a critical value that depends on nn and the significance level (2.132.13 for n=8n = 8 at 5 %5\,\%, 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

s/ns/\sqrt{n} assumes independent readings. Readings taken faster than the instrument's noise changes (a DMM sampling every 20 ms20\ \text{ms} during a thermal drift, or 1/f1/f noise in an amplifier) are correlated, and s/ns/\sqrt{n} is then too optimistic. A quick check is the lag-1 autocorrelation r1r_1 of the readings; for an AR(1)-like process an effective number of independent readings is

neff≈n 1−r11+r1n_\text{eff} \approx n\,\frac{1 - r_1}{1 + r_1}

When r1r_1 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: 1000.121000.12, 1000.151000.15, 1000.091000.09, 1000.141000.14, 1000.111000.11, 1000.131000.13, 1000.101000.10, 1000.421000.42. The notebook records nothing unusual for the last one.

Find: whether to reject the last reading, then the mean and its 95 %95\,\% interval.

Solve: with all eight readings, xˉ=1000.1575 Ω\bar{x} = 1000.1575\ \Omega and s=0.1079 Ωs = 0.1079\ \Omega. The farthest point is 1000.42 Ω1000.42\ \Omega:

G=1000.42−1000.15750.1079=2.43>2.13G = \frac{1000.42 - 1000.1575}{0.1079} = 2.43 > 2.13

so Grubbs flags it. Without it (n=7n = 7), xˉ=1000.1200 Ω\bar{x} = 1000.1200\ \Omega, s=0.0216 Ωs = 0.0216\ \Omega, sxˉ=0.0082 Ωs_{\bar{x}} = 0.0082\ \Omega, t0.975,6=2.447t_{0.975,6} = 2.447:

xˉ±t sxˉ=1000.120±2.447×0.0082 Ω=1000.120±0.020 Ω\bar{x} \pm t\,s_{\bar{x}} = 1000.120 \pm 2.447 \times 0.0082\ \Omega = 1000.120 \pm 0.020\ \Omega

Check: the interval is a few hundredths of an ohm, consistent with the spread of the seven readings (0.06 Ω0.06\ \Omega from smallest to largest); the rejected reading is 0.30 Ω0.30\ \Omega 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).

python · try it yourself
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 σ\sigma of the readings. Ten readings with σ=0.8 mm\sigma = 0.8\ \text{mm} typically span about 3σ=2.4 mm3\sigma = 2.4\ \text{mm}, so the school "half the range" rule gives about 1.2 mm1.2\ \text{mm}, while s/10s/\sqrt{10} is about 0.25 mm0.25\ \text{mm}.

Simulation. The lab takes one reading a second on a 0.1 mm0.1\ \text{mm} vernier. With these settings the ten readings run from 51.351.3 to 54.4 mm54.4\ \text{mm} (mean 52.62 mm52.62\ \text{mm}); the half-range rule ends at 53±2 mm53 \pm 2\ \text{mm} and the mean-deviation rule at 52.6±0.9 mm52.6 \pm 0.9\ \text{mm}. From the same ten numbers, s=0.99 mms = 0.99\ \text{mm} and s/10=0.31 mms/\sqrt{10} = 0.31\ \text{mm}. 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.

10 of 10 readings of the length (mm)50515253545556range 3.1 mmx̄ = 52.620result: 53 ± 2 mmΔx = (max − min)/2, at least ½ division56cm0510main scale 51 mm + vernier line 7 lines up (7 × 0.1 mm)reading 51.7 mm ± 0.05 mm (half of 0.1 mm)

What you would measure. Take 20 readings of a 1 kΩ1\ \text{k}\Omega, 0.1 %0.1\,\% resistor with a 5½-digit DMM, one every 5 s. Expect ss of one or two counts (1010 to 20 mΩ20\ \text{m}\Omega), a mean within the resistor's tolerance, and r1r_1 near zero. Then hold the resistor in your fingers between readings: the warming drift makes r1r_1 approach 1 and the "uncertainty of the mean" meaningless.

Hazards and safe setup. None beyond the meter itself: the ohms function drives about 1 mA1\ \text{mA}.

Pitfalls

  • Using np.std without ddof=1 (population formula) for a handful of readings.
  • Quoting ±2sxˉ\pm 2 s_{\bar{x}} as a 95 %95\,\% 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 s/ns/\sqrt{n}.

Practice

  1. Five readings have s=4.0 mVs = 4.0\ \text{mV}. Give the standard uncertainty of the mean and the 95 %95\,\% half-width.
  2. Readings of r1=0.5r_1 = 0.5: how many independent readings are 40 correlated ones worth?
Answer
  1. sxˉ=4.0/5=1.79 mVs_{\bar{x}} = 4.0/\sqrt{5} = 1.79\ \text{mV}; half-width 2.78×1.79=5.0 mV2.78 \times 1.79 = 5.0\ \text{mV}.
  2. neff=40×0.5/1.5=13n_\text{eff} = 40 \times 0.5/1.5 = 13.

Test yourself

The Type A standard uncertainty of the mean of nn readings is

  1. ss
  2. s/ns/\sqrt{n}
  3. s/ns/n
  4. the range divided by 2

Why use the t-factor instead of 1.96 for five readings?

  1. The readings are not normal
  2. ss is itself uncertain with few readings
  3. It makes the interval smaller
  4. The GUM forbids 1.96

A reading is far from the others and the notebook records that the probe slipped. You should

  1. keep it, data are data
  2. strike it out with the reason recorded
  3. run Grubbs' test repeatedly
  4. average it in with a lower weight

Readings with lag-1 autocorrelation r1=0.8r_1 = 0.8 have

  1. more information than independent ones
  2. about one ninth as many effective readings
  3. no effect on the uncertainty
  4. a smaller ss, so a smaller uncertainty