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.

Every experiment in this manual ends in a number with an uncertainty. This section is the reference for how that uncertainty is obtained. Read it once now, and come back to it in Weeks 3, 6, and 13, where it does the most work.

What an uncertainty means

A result quoted as x=633.4±0.8 nmx = 633.4 \pm 0.8\ \text{nm} needs a stated meaning for the 0.8 nm0.8\ \text{nm}. In this manual, an uncertainty written as σ\sigma is a standard uncertainty, comparable to one standard deviation. If the uncertainty model is approximately normal, an interval of one σ\sigma covers about 68% of that distribution, and two σ\sigma about 95%. These are model based coverage statements, not guarantees or worst-case bounds. State a different coverage factor when you report an expanded uncertainty.

Two methods are used to evaluate uncertainty components.

Type A components are evaluated statistically, often from repeated measurements. For independent readings under stable conditions, the standard uncertainty of their mean falls as 1/N1/\sqrt{N}. The scatter of individual readings does not fall merely because you collect more of them.

Type B components are evaluated by other information, such as an instrument specification, calibration certificate, scale resolution, or a bound on a geometric offset. Type A and Type B describe how a component was evaluated, not whether its effect is random or systematic. A shared calibration offset, for example, is not reduced by repeating readings with the same instrument. Decide which effects are shared before assuming that more measurements will improve the result. See NIST TN 1297, §§2–4.

Estimating a Type A uncertainty

For N≥2N \ge 2 repeated measurements xix_i of the same quantity, the sample standard deviation

s=1N−1∑i=1N(xi−xˉ)2s = \sqrt{\frac{1}{N-1}\sum_{i=1}^{N}(x_i - \bar{x})^2}

estimates the spread of a single reading, and the standard error of the mean

σxˉ=sN\sigma_{\bar{x}} = \frac{s}{\sqrt{N}}

is the standard uncertainty of the average if the readings are independent and the conditions stable. The distinction matters: ss estimates the spread of individual readings, while σxˉ\sigma_{\bar{x}} describes the precision of their mean. Report the second when the mean is your result, but look at the first — if ss is much larger than the instrument’s resolution, something is fluctuating and it is worth knowing what. Neither expression includes a shared calibration error.

Estimating a Type B uncertainty

Common cases:

Source

Standard uncertainty

Digital display, step size dd

d/12≈0.29 dd/\sqrt{12} \approx 0.29\,d if rounding is the only effect and the unknown position within a step is modeled as uniform

Analog scale, division DD

Estimate the reading limit from the actual scale and viewing conditions; do not assign a quarter division automatically

Manufacturer’s spec “±a\pm a” as a bound, with no distribution stated

a/3a/\sqrt{3} if a uniform distribution over ±a\pm a is a reasonable model; record that assumption

Manufacturer’s spec “±a\pm a at 95% confidence”

Approximately a/2a/2 if the specification uses a normal model; check its stated coverage factor when available

A quantity you can bound between x−x_- and x+x_+ and know nothing else

(x+−x−)/12(x_+ - x_-)/\sqrt{12} if a uniform distribution over that interval is a reasonable model

Combine independent Type A and Type B contributions in quadrature: σ2=σA2+σB,12+σB,22+⋯\sigma^2 = \sigma_A^2 + \sigma_{B,1}^2 + \sigma_{B,2}^2 + \cdots. If components share a source, include their covariance instead.

Propagating uncertainty

For a result f(x,y,…)f(x, y, \ldots) computed from independently measured quantities,

σf2=(∂f∂x)2σx2+(∂f∂y)2σy2+⋯\sigma_f^2 = \left(\frac{\partial f}{\partial x}\right)^2\sigma_x^2 + \left(\frac{\partial f}{\partial y}\right)^2\sigma_y^2 + \cdots

Two shortcuts cover most cases in this manual:

If the derivatives are unpleasant, estimate them numerically by perturbing each input and recomputing the result. Add the resulting contributions in quadrature only for independent inputs; retain covariance terms when inputs are correlated. For a strongly nonlinear function or large uncertainties, check the linear approximation with a simulation of the input distributions.

Fitting a model to data

Most experiments here reduce to: fit a model y=f(x;θ)y = f(x; \theta) to data and report the parameters θ\theta with their uncertainties. The parameter is the physics; the fit is bookkeeping.

Weighted least squares

Given data (xi,yi)(x_i, y_i) with uncertainties σi\sigma_i on yy, choose the parameters that minimize

χ2(θ)=∑i=1N[yi−f(xi;θ)]2σi2.\chi^2(\theta) = \sum_{i=1}^{N} \frac{\left[y_i - f(x_i;\theta)\right]^2}{\sigma_i^2}.

Each residual is measured in units of its own uncertainty, so a point you know well pulls the fit harder than one you do not. Supply the σi\sigma_i when you have defensible uncertainty estimates; an unweighted fit treats the points as having equal variance. Counts with widely different magnitudes, for example, generally do not meet that assumption. This formula also assumes independent yiy_i errors and negligible uncertainty in xix_i; revisit the fit method if either assumption fails.

Reading the fit

Three numbers come out, and all three matter.

The parameters θ^\hat\theta — the physics.

Their estimated uncertainties, the square roots of the diagonal of the covariance matrix, σθj=Cjj\sigma_{\theta_j} = \sqrt{C_{jj}}, provided the fit model and uncertainty assumptions are reasonable.

The reduced chi-square, χν2=χmin⁡2/ν\chi^2_\nu = \chi^2_{\min}/\nu with ν=N−p\nu = N - p degrees of freedom for pp fitted parameters. It is a self-consistency check on your uncertainty estimates:

For small ν\nu, this ratio fluctuates substantially even under a good model; do not treat these descriptions as fixed pass/fail thresholds.

Always plot the residuals (yi−f(xi;θ^))/σi(y_i - f(x_i;\hat\theta))/\sigma_i against xix_i. A fit is judged by its residuals, not by how good the curve looks on top of the data.

Correlation between parameters

The off-diagonal elements of CC are not decoration. In a straight-line fit y=mx+by = mx + b over data far from the origin, mm and bb are strongly anticorrelated, and ignoring that correlation can misstate how well you know f(x)f(x) at a particular xx. When a derived quantity depends on more than one fitted parameter — as in Experiment 6, where hh comes from a slope and the work function from an intercept — propagate with the full covariance matrix:

σg2=∑j∑k∂g∂θj∂g∂θkCjk.\sigma_g^2 = \sum_{j}\sum_{k} \frac{\partial g}{\partial \theta_j}\frac{\partial g}{\partial \theta_k} C_{jk}.

Linearize with care

It is tempting to fit an exponential N(t)=N0e−λtN(t) = N_0 e^{-\lambda t} by taking logarithms and fitting a straight line. This is legitimate only if you transform the uncertainties too: if NN has uncertainty σN\sigma_N, then ln⁡N\ln N has uncertainty σN/N\sigma_N/N, so the late-time points — which have small absolute uncertainty but large relative uncertainty — must be down-weighted. An unweighted fit to ln⁡N\ln N gives systematically wrong decay constants. Prefer fitting the exponential directly; if you linearize, weight correctly and say in the report that you did. At low counts, the log transform also distorts the error distribution, so a count-based likelihood may be more appropriate.

For Poisson-distributed counts NN, the uncertainty is N\sqrt{N} — see Counting Statistics, Half-Life, and Gamma Attenuation for why, and for the case N=0N = 0, where N\sqrt{N} is not usable.

Comparing to an accepted value

Quote the discrepancy in units of the combined uncertainty:

t=∣xmeas−xacc∣σmeas2+σacc2.t = \frac{\left|x_{\text{meas}} - x_{\text{acc}}\right|} {\sqrt{\sigma_{\text{meas}}^2 + \sigma_{\text{acc}}^2}}.

Treat tt as a standardized discrepancy when the two estimates are independent, their quoted uncertainties are comparable standard uncertainties, and a normal approximation is reasonable. A value near or above 2 invites a closer look; a large value warrants investigation of the model and uncertainty budget. It does not identify the cause by itself. If the accepted-value uncertainty is negligible, say so and omit that term. Never use percent difference alone — a 3% discrepancy is excellent for the muon flux and catastrophic for the Rydberg constant, and only the uncertainty tells you which situation you are in.

Worked template

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

def model(x, m, b):
    """Replace with the physics. x, m, b are floats or arrays."""
    return m * x + b

x  = np.array([...])          # independent variable
y  = np.array([...])          # measured values
sy = np.array([...])          # 1-sigma uncertainty on each y  (never omit)

p0 = [1.0, 0.0]               # a starting guess that is roughly right matters
                              # more for nonlinear models than students expect

popt, pcov = curve_fit(model, x, y, p0=p0, sigma=sy, absolute_sigma=True)
perr = np.sqrt(np.diag(pcov))

resid = (y - model(x, *popt)) / sy
chi2  = np.sum(resid**2)
nu    = len(x) - len(popt)

for name, val, err in zip(["m", "b"], popt, perr):
    print(f"{name} = {val:.6g} +/- {err:.2g}")
print(f"chi2/nu = {chi2/nu:.2f}  (nu = {nu})")

fig, (ax, axr) = plt.subplots(
    2, 1, sharex=True, height_ratios=[3, 1], figsize=(6, 5)
)
xs = np.linspace(x.min(), x.max(), 400)
ax.errorbar(x, y, yerr=sy, fmt="o", capsize=3, label="data")
ax.plot(xs, model(xs, *popt), "-", label="fit")
ax.set_ylabel("y  [unit]")
ax.legend()

axr.axhline(0, lw=0.8)
axr.errorbar(x, resid, yerr=1, fmt="o", capsize=3)
axr.set_xlabel("x  [unit]")
axr.set_ylabel(r"residual / $\sigma$")
fig.tight_layout()