Skip to content
Tactiverge

School/✦ Research Engineer/Week 8

Fitting and validating a model against data

A recorded decay gives you seven peaks. How do you get the damping out of them, and how do you know the model deserved to be fitted?

About 50 min · 3 goals · Checked by automated tests

1.Why should I care?

A model's parameters are rarely known in advance. Engineers measure, fit, and then test the fit on fresh data. This is the honest loop between theory and reality, and the skills carry straight into estimation next term.

  • ◇ Linearise an exponential decay with logarithms and estimate ζω_n by least squares.
  • ◇ Validate a fitted model on data not used for fitting and quantify its error.
  • ◇ Interpret residual patterns as evidence for or against the model's assumptions.

2.Predict

Peak amplitudes of a decaying oscillation are plotted as ln(peak) against time. If the model with linear damping is right, what shape do you expect?

Guess first. Being wrong here is how the surprise works.

3.Understand

Question → method → evidence

Question: what is the damping, and does linear damping describe this system? Method: extract peaks, fit ln(peak) against t, then predict a second recording. Evidence: the fitted slope with its uncertainty, residual plot, and prediction error on the held-out recording.

A worked fit

For the diagram's decay data (peaks at t = 0…6 s), least squares gives slope −0.304 per second and intercept 0.012. So ζω_n ≈ 0.30 s⁻¹ and A₀ ≈ e^{0.012} ≈ 1.01. If the peak spacing gives ω_d = 2.0 rad/s, then ω_n ≈ 2.02 rad/s and ζ ≈ 0.15.

Validation, not just fitting

A model can always be fitted to the data it was fitted to. Validation uses different data: a second run, another amplitude, a different day. Report the prediction error there. Patterned residuals (for example a curve in ln(peak)) suggest a wrong assumption, such as friction that does not scale with speed.

Explain it another way

Fitting is tailoring a suit to someone; validation is checking it still fits when they walk around.

Derivation: Turning a decay into a straight-line fit
  1. Underdamped solution: x(t) = A₀ e^{−ζω_n t} cos(ω_d t + φ). Peaks occur about every 2π/ω_d with heights Aₖ ≈ A₀ e^{−ζω_n tₖ}.

  2. Take logs: ln Aₖ = ln A₀ − (ζω_n) tₖ. This is linear in the unknowns (ln A₀, ζω_n).

  3. Fit yₖ = ln Aₖ against tₖ by least squares (week 5): slope m = −ζω_n, intercept c = ln A₀.

  4. With ω_d measured from the peak spacing, ω_n = √(ω_d² + (ζω_n)²), so ζ = (ζω_n)/ω_n.

  5. Caution: taking logs changes the noise. Small peaks have large relative noise, so ln weights them oddly; with good data this is a small effect, but it should be stated.

Worked example 1

Peaks: 1.00, 0.74, 0.55, 0.41 at t = 0, 1, 2, 3 s. Estimate ζω_n.

ln peaks: 0, −0.301, −0.598, −0.892. These fall by about 0.297 per second; the least-squares slope is −0.297, so ζω_n ≈ 0.30 s⁻¹.

Common mix-ups

  • A good fit proves the model.
    ✓ It shows consistency with that data. Validation on new data and residual checks are needed.
  • Taking logs is harmless.
    ✓ It changes how noise is weighted; say so, and check with a direct nonlinear fit if precision matters.

4.Discover

Choose 'Damped decay, ln(amplitude)'. Fit a line by hand, then reveal the least-squares line. Read the slope: that is −ζω_n. Look at the residuals: are they random?

Loading the interactive…

Can't use the interactive? Read a description instead

The least-squares diagram with the damped-decay data set plots ln(peak amplitude) against time, with your line, residual segments and, on request, the best-fit line. Text reports slopes, intercepts and sums of squared residuals.

5.Checkpoint: guided practice

Check what you just discovered before going on. Hints appear after a wrong answer.

Practice 1 · a fresh version every time

Fit y = m·x + c by least squares to the points (0, 1.3), (1, 1.8), (2, 1.8), (3, 2.6), (4, 3.2). What is the slope m?

6.Practice on your own

Practice, not a test. Wrong answers get a hint and another try.

Practice 2

A ln(peak) fit gives slope −0.5 s⁻¹ and ω_n = 10 rad/s. What is ζ?

Practice 3

Which is the best evidence that your fitted model is useful?

Practice 4

ln(peak) residuals curve upwards at late times. A plausible explanation?

Practice 5 · a fresh version every time

Fit y = m·x + c by least squares to the points (0, 0.1), (1, 2), (2, 4), (3, 6), (4, 7.8), (5, 9.7). What is the slope m?

7.Apply it

Record (or simulate with added noise) two decays of the same oscillator. Fit ζω_n on the first, predict the peaks of the second, and report the root-mean-square prediction error and what it suggests.

8.Reflect

9.Go further

Research mode: limits and open questions

Next term this becomes formal estimation: least squares as an estimator with bias, variance and confidence intervals.

    Concepts: Mathematical modelling and validation · Fitting lines with least squares · Measurement error and uncertainty