Data Analysis

Chapter 6 of 11 · 11 min read

Linearising a relation

Turning power laws, exponentials and odd model functions into straight lines, so that a ruler (or least squares) gives the physics.

Why straight lines

The human eye can judge a straight line accurately and a curve only poorly. And a straight line has just two parameters, slope and intercept, which you can read and give errors for. So whenever a model is y=f(x;A,B)y = f(x; A, B), look for new variables X(x)X(x) and Y(y)Y(y) such that

Y=mX+c,Y = mX + c,

with mm and cc simple functions of the unknowns AA and BB.

The standard transformations

  • Power law y=Axny = Ax^n (Kepler's third law, mass–luminosity, the Cepheid L∝PβL\propto P^\beta): log⁡y=nlog⁡x+log⁡A\log y = n\log x + \log A. Plot log⁡y\log y against log⁡x\log x; the slope is the exponent.
  • Exponential y=Aekxy = Ae^{kx} (decays, N=N0e−t/τN = N_0e^{-t/\tau}): ln⁡y=kx+ln⁡A\ln y = kx + \ln A.
  • Magnitudes are already logarithms. M=β′log⁡P+C′M = \beta'\log P + C' is a straight line in MM against log⁡P\log P, with β′=−2.5β\beta' = -2.5\beta. The same applies to atmospheric extinction, m=m0+kXm = m_0 + kX against airmass XX.
  • Inverse relations such as Wien's law λmax⁡=b/T\lambda_{\max} = b/T: plot λmax⁡\lambda_{\max} against 1/T1/T.
  • Kepler's third law a3=GM4π2P2a^3 = \dfrac{GM}{4\pi^2}P^2: plot a3a^3 against P2P^2, or log⁡a\log a against log⁡P\log P (slope 2/3).
  • Hubble's law v=H0dv = H_0d: already linear, and should pass through the origin.

Custom variables

Recent problems often hand you an awkward model and expect you to find the variable that makes it linear.

2017 D2 (cored dark matter halo). MDM(r)=4πρ0rC2[r−rCarctan⁡(r/rC)]M_{\rm DM}(r) = 4\pi\rho_0r_C^2\left[r - r_C\arctan(r/r_C)\right]. Once rCr_C is known, define X=r−rCarctan⁡(r/rC)X = r - r_C\arctan(r/r_C). Then MDM=(4πρ0rC2)XM_{\rm DM} = (4\pi\rho_0r_C^2)X, a straight line through the origin whose slope gives ρ0\rho_0.

2023 DA2 (astrometric microlensing). Δθ=θE u/(u2+2)\Delta\theta = \theta_E\,u/(u^2+2). With X=u/(u2+2)X = u/(u^2+2) this is Δθ=θEX\Delta\theta = \theta_EX: the slope is the Einstein radius.

2018 D1 (UV slope). fλ∝λβf_\lambda\propto\lambda^\beta becomes mAB=−2.5(β+2)log⁡λ+constm_{\rm AB} = -2.5(\beta+2)\log\lambda + {\rm const}, so a line in mABm_{\rm AB} against log⁡λ\log\lambda has slope −2.5(β+2)-2.5(\beta+2).

The recipe: isolate the unknown you want as a multiplicative constant, then call everything it multiplies XX.

Errors after a transformation

Transform the error bars too. If Y=log⁡10yY = \log_{10}y, then ΔY=Δy/(yln⁡10)\Delta Y = \Delta y/(y\ln10). Error bars that were equal in yy become unequal in log⁡y\log y, which is a reason to use a weighted fit afterwards.

Put the quantity with the largest relative error on the vertical axis. Ordinary least squares assumes xx is exact.

Finally, check the result is straight. If the transformed points still curve, the model or a parameter is wrong. In 2017 D2, using the fallback rC=3.2r_C = 3.2 kpc makes the MDMM_{\rm DM}–XX plot visibly bent, which tells you that value is wrong.

Key formulas

Power law
y=Axn  ⟹  log⁡y=nlog⁡x+log⁡Ay = Ax^n \;\Longrightarrow\; \log y = n\log x + \log A
Exponential
y=Aekx  ⟹  ln⁡y=kx+ln⁡Ay = Ae^{kx} \;\Longrightarrow\; \ln y = kx + \ln A
Error of a logarithm
Δ(log⁡10y)=Δyy ln⁡10\Delta(\log_{10} y) = \frac{\Delta y}{y\,\ln 10}

Common mistakes

  • Plotting y against log x when the model is a power law (both axes need logs).
  • Forgetting that a magnitude is already a logarithm and taking its log again.
  • Keeping the original error bars after transforming the variable.
  • Not checking that the transformed data actually look straight.

Practise this chapter

Past IOAA problems that use these skills.

Saved in this browser only.