LearnQuestion bank

Derive the maximum-likelihood estimates of a Gaussian’s mean and variance from n samples. Is the variance estimate unbiased, and what does that say about MLE in general?

ResearchTechnicalMedium

Answer it yourself first, out loud or on paper, then compare.

Answer

Model answer, written in a candidate's voice

In short

  • Write ℓ(μ,σ²) and differentiate: μ̂ = x̄, σ̂² = (1/n)Σ(x_i−x̄)².
  • E[σ̂²] = (n−1)σ²/n, so it is biased low; Bessel’s correction s² = (1/(n−1))Σ(x_i−x̄)² is unbiased.
  • MLE is consistent, asymptotically efficient and invariant, but finite-sample biased.
  • Deep learning: minimising NLL is cross-entropy training for softmax/categorical models; Gaussian NLL is MSE plus a log-variance term.

In full

For iid x_i ~ N(μ,σ²), ℓ = -n/2 log(2π) - n/2 log σ² - [Σ(x_i−μ)²]/(2σ²). Setting ∂ℓ/∂μ = Σ(x_i−μ)/σ² = 0 gives μ̂ = x̄, and setting ∂ℓ/∂σ² = -n/(2σ²) + Σ(x_i−μ̂)²/(2σ⁴) = 0 gives σ̂² = (1/n)Σ(x_i−x̄)². This is not unbiased: since Σ(x_i−x̄)² = Σ(x_i−μ)² − n(x̄−μ)² and Var(x̄) = σ²/n, E[Σ(x_i−x̄)²] = nσ² − σ² = (n−1)σ², so E[σ̂²] = (n−1)σ²/n, and Bessel’s correction s² = (1/(n−1))Σ(x_i−x̄)² is the unbiased version. In general MLE is consistent, asymptotically efficient and invariant to reparameterisation, but it can be biased in finite samples, with bias typically O(1/n). The link to deep learning: minimising negative log-likelihood is the same as cross-entropy training for softmax/categorical models, while for a Gaussian it is a weighted squared error plus a log-variance penalty.

Corrected by an independent AI reviewer.

What a strong answer covers

  • Writes the log-likelihood and differentiates. μ̂ is the sample mean; σ̂² = (1/n)Σ(x−μ̂)².
  • E[σ̂²] = (n−1)σ²/n, so the estimate is biased; Bessel’s correction fixes it.
  • MLE is consistent, asymptotically efficient and invariant, but can be biased with finite samples.
  • Links to deep learning: minimising NLL is the same as cross-entropy training.

Common mistakes

  • Dividing by n−1 and calling the result the MLE.
  • Skipping the derivation.