TactivergeLite

Lite / Independent Engineering Research / Week 11

Maximum likelihood

A probe's detector counted 12 dust impacts in 4 hours. What impact rate makes that observation least surprising?

About 40 min · 3 goals · Checked by automated tests · Full interactive version

Why should I care?

When you have a model with an unknown parameter, maximum likelihood is the default way to fit it: rates of failures, success probabilities, noise variances. It also underlies least squares, the workhorse of calibration.

Predict

A camera sees the landmark 7 times in 10 attempts (binomial). What is the maximum-likelihood estimate of p?

  1. 0.5
  2. 0.7
  3. 0.75
  4. It depends on the prior
Guess first, then reveal

p̂ = k/n = 0.7. The likelihood p⁷(1 − p)³ peaks there. No prior is involved: that is the Bayesian idea for week 13.

Discover

Keep the flat prior. Add 7 successes and 3 failures. With a flat prior the posterior is just the normalised likelihood, so its peak is the MLE: check it sits at 0.7. Add more data in the same ratio and watch the peak stay put while it narrows.

What the interactive shows (text version)

With a flat prior, the grid's posterior bars are the normalised likelihood; the readout states the peak value and k/n, which match. All values appear in the text readout.

You can also open the interactive on the full site when you have a faster connection.

Watch (optional)

Watch for: Watch the curve slide along the data: the best position is where the observed points are most probable.

Explains maximum likelihood by sliding a distribution along the data until the observations look most probable.

“Maximum Likelihood, clearly explained!!!” by StatQuest with Josh Starmer (opens YouTube; streaming video uses a lot of data)

The video is optional. Everything you need is in this lesson's text.

Understand

Likelihood

Given a model P(data | θ), the likelihood L(θ) is that same expression read as a function of θ, with the data fixed. It is not a probability distribution over θ (it need not integrate to 1). The MLE θ̂ maximises L, or equivalently the log-likelihood ℓ = ln L, which turns products into sums.

Two classic results

Binomial: ℓ(p) = k ln p + (n − k) ln(1 − p) + c; dℓ/dp = 0 gives p̂ = k/n. Poisson with rate λ over time T: ℓ(λ) = k ln(λT) − λT + c; dℓ/dλ = k/λ − T = 0 gives λ̂ = k/T. The MLE is usually the 'obvious' estimate, now with a justification.

Gaussian noise gives least squares

If yᵢ = f(xᵢ; θ) + εᵢ with εᵢ ~ N(0, σ²) independent, then ℓ(θ) = −Σ(yᵢ − f(xᵢ; θ))²/(2σ²) + c. Maximising ℓ is minimising the sum of squared residuals. Least squares is the MLE when the noise is Gaussian, and only then is it guaranteed optimal in this sense.

Explain it another way

Intuitive

Try every possible rate. For each, ask 'how likely was what I saw?' Pick the rate that makes your data least surprising.

Technical

Under regularity conditions the MLE is consistent and asymptotically normal with variance 1/I(θ), the inverse Fisher information. For Poisson, I(λ) = T/λ, so SE(λ̂) ≈ √(λ̂/T).

Mathematical

Binomial: d/dp [k ln p + (n − k) ln(1 − p)] = k/p − (n − k)/(1 − p) = 0 ⇒ k(1 − p) = (n − k)p ⇒ p = k/n.

Applied

Reliability engineers estimate failure rates of components from test hours with exactly this formula, then use the SE to decide how many more test hours are needed.

Derivation: The MLE of a Poisson rate
  1. k events in time T, rate λ: P(k | λ) = e^(−λT)(λT)ᵏ / k!.

  2. Log-likelihood: ℓ(λ) = −λT + k ln λ + k ln T − ln k!.

  3. Differentiate: dℓ/dλ = −T + k/λ.

  4. Set to zero: λ̂ = k/T. Second derivative −k/λ² < 0, so it is a maximum.

  5. Example: 12 impacts in 4 h gives λ̂ = 3 per hour.

Worked example 1

12 micrometeoroid impacts are recorded in 4 hours. MLE of the rate and its approximate standard error?

λ̂ = 12/4 = 3 per hour. SE ≈ √(λ̂/T) = √(3/4) ≈ 0.87 per hour.

Common mix-ups

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

per hour

Practice 3. Least squares is the maximum-likelihood fit when the measurement noise is…
Practice 4. Which is true of the likelihood L(θ)?

per s

Apply it

Your rover's hazard camera false-alarms 3 times in 600 frames. Estimate the false-alarm rate and its standard error. How many frames would you need to halve the SE?

Reflect

Why do we usually maximise the log-likelihood instead of the likelihood itself?

Write your answer on paper or in your own notes. Lite never stores what you write.

← Estimators: bias, variance and errorLeast squares as an estimator →