Skip to main content

6.6 Exponential decay and least-squares fitting

Source: Ideas from Computational Physics (Landau, Páez, Bordeianu), §6.6–6.7.2. Rewritten in original wording. Continues 6.5.2b Cubic splines labs. Labs: 6.6b Least-squares fitting labs.

Fitting exponential decay​

Real particle-decay measurements — such as the number of π\pi-meson decays ΔN\Delta N recorded in 10-ns time bins — are noisy and finite in number, unlike the smooth theoretical curve they're compared against. Given such data, the problem is to deduce a physical constant, the particle lifetime τ\tau, from the scatter.

The underlying physics is a stochastic process: in a short time Δt\Delta t, the number of decays ΔN\Delta N out of N(t)N(t) remaining particles is proportional to both N(t)N(t) and Δt\Delta t:

ΔN(t)=−1τN(t) Δt⇒ΔN(t)Δt=−λN(t),\Delta N(t)=-\frac1\tau N(t)\,\Delta t \quad\Rightarrow\quad \frac{\Delta N(t)}{\Delta t}=-\lambda N(t),

with τ=1/λ\tau=1/\lambda the lifetime. Taking Δt→0\Delta t\to 0 yields dN/dt=−λNdN/dt=-\lambda N, whose solution is exponential decay N(t)=N0e−t/τN(t)=N_0e^{-t/\tau} — the curve to fit (compare τ\tau against the tabulated pion lifetime 2.6×10−8 2.6\times10^{-8}\,s). The walk below linearizes that fit and recovers τ\tau from a straight line.

Why "best fit" doesn't mean "passes through every point"​

Three points frame all of least-squares fitting:

  1. If the data carry real experimental error, the statistically "best" fit will not pass through every data point — forcing that (as Lagrange interpolation does) actually makes the fit worse, not better.
  2. If the assumed theoretical form is wrong for the data, its best fit may simply be a poor fit — and that's useful information, since it tells you the theory doesn't apply.
  3. Only the simplest case — a fit linear in its parameters — has a closed-form solution. Everything else needs a trial-and-error numerical search (Section 6.8).

Chi-square and linear least squares​

Given NDN_D measurements (xi,yi±σi)(x_i,y_i\pm\sigma_i) and a theory g(x;{am})g(x;\{a_m\}) with MPM_P parameters, least-squares fitting adjusts the ama_m to minimize χ2\chi^{2}. When g=a1+a2xg=a_1+a_2x the stationarity conditions are linear — closed formulas for a1,a2a_1,a_2 (and a stabler centered form). Walk χ2→∂χ2=0→\chi^{2}\to\partial\chi^{2}=0\to normal equations — pick the matching formula at each step.

If gg depends on the ama_m nonlinearly, the same stationarity conditions become a nonlinear system — search (Section 6.8), trying several starts so a found minimum is global.

Rule of thumb (Gaussian errors): a good fit has χ2≃ND−MP\chi^{2}\simeq N_D-M_P. Much smaller usually means too many parameters or overestimated σi\sigma_i; much larger usually means a bad theory or underestimated errors. If σi\sigma_i is unknown, a common fallback is σi≡1\sigma_i\equiv 1.

Parameter uncertainties and correlation follow from the same weighted sums: σa12=Sxx/Δ\sigma_{a_1}^{2}=S_{xx}/\Delta, σa22=S/Δ\sigma_{a_2}^{2}=S/\Delta, cov⁡(a1,a2)=−Sx/Δ\operatorname{cov}(a_1,a_2)=-S_x/\Delta, and ρ=cov⁡/(σa1σa2)∈[−1,1]\rho=\operatorname{cov}/(\sigma_{a_1}\sigma_{a_2})\in[-1,1].

Turning exponential decay into a linear fit​

N(t)=N0e−t/τN(t)=N_0e^{-t/\tau} is nonlinear in τ\tau, but a logarithm linearizes it. Pick the decay law, the ln⁡N\ln N line, and the recovery formulas among lookalikes.

Extending to a quadratic (still linear in the parameters!)​

g(x)=a1+a2x+a3x2g(x)=a_1+a_2x+a_3x^2 is still a linear fit — linearity refers to the dependence on the aa's, not on xx. (By contrast, g(x)=(a1+a2x)e−a3xg(x)=(a_1+a_2x)e^{-a_3x} is not linear, because a3a_3 appears inside the exponential.) Minimizing χ2\chi^2 for the quadratic gives three simultaneous linear equations in a1,a2,a3a_1,a_2,a_3:

Sa1+Sxa2+Sxxa3=Sy,Sxa1+Sxxa2+Sxxxa3=Sxy,Sxxa1+Sxxxa2+Sxxxxa3=Sxxy,\begin{aligned} Sa_1+S_xa_2+S_{xx}a_3&=S_y,\\ S_xa_1+S_{xx}a_2+S_{xxx}a_3&=S_{xy},\\ S_{xx}a_1+S_{xxx}a_2+S_{xxxx}a_3&=S_{xxy}, \end{aligned}

with Sxxx=∑xi3/σi2S_{xxx}=\sum x_i^3/\sigma_i^2, Sxxxx=∑xi4/σi2S_{xxxx}=\sum x_i^4/\sigma_i^2, Sxxy=∑xi2yi/σi2S_{xxy}=\sum x_i^2y_i/\sigma_i^2 extending the earlier sums. In matrix form this is Aa⃗=b⃗A\vec a=\vec b with

A=[SSxSxxSxSxxSxxxSxxSxxxSxxxx],a⃗=[a1a2a3],b⃗=[SySxySxxy].A=\begin{bmatrix}S&S_x&S_{xx}\\S_x&S_{xx}&S_{xxx}\\S_{xx}&S_{xxx}&S_{xxxx}\end{bmatrix},\qquad \vec a=\begin{bmatrix}a_1\\a_2\\a_3\end{bmatrix},\qquad \vec b=\begin{bmatrix}S_y\\S_{xy}\\S_{xxy}\end{bmatrix}.

For 3×33\times3 a closed form exists, but larger problems need a numerical linear solve — the same kind of Gaussian-elimination machinery used for the cubic-spline system in the previous lesson. This pattern — more parameters, same structure — is exactly why linear algebra libraries (Chapter 7) matter for fitting realistic models.

Quiz

Least-squares fitting

1 / 4

chi-square weights each residual by…

Pick an answer to see if you are right.

Next: 6.6b Least-squares fitting labs.