Week 7.2: Maximum Likelihood Estimation (MLE)
622 words
3 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Week 7.2: Maximum Likelihood Estimation (MLE) > **Prerequisites:** Independence ([Week 2.3: Independence of Random Variables](/notes/01-foundation-bsma1004-stats-2-week02-07-independence)), MME ([Week 7.1: Point Estimation — Method of Moments (MME)](/notes/01-foundation-bsma1004-stats-2-week07-20-point-estimation-...

Week 7.2: Maximum Likelihood Estimation (MLE)
Prerequisites: Independence (Week 2.3: Independence of Random Variables), MME (Week 7.1: Point Estimation — Method of Moments (MME)) Cross-links: BSMA3012 (Linear Stat Models) — MLE for regression Core question: Which parameter value makes the observed data most probable?
1. Intuition: "What value of θ best explains the data?"
The likelihood function L(θ)=∏i=1nfX(xi;θ) measures how "likely" the observed data is for a given θ. The maximum likelihood estimator (MLE) θ^MLE is the value of θ that maximises L(θ) — the value that makes the data most probable.
Key insight: We maximise the log-likelihood ℓ(θ)=lnL(θ) for computational convenience — the logarithm is monotonic, so the maximiser is the same.
2. The Recipe
Algorithm:
- Write the likelihood: L(θ)=∏i=1nf(xi;θ).
- Take log: ℓ(θ)=lnL(θ).
- Differentiate: dθdℓ (or partial derivatives for vector θ).
- Set to zero and solve for θ.
- Verify second derivative is negative (maximum).
3. Worked Examples
Example 1: Bernoulli(p)
Xi∼Bernoulli(p) i.i.d.
L(p)=∏i=1npxi(1−p)1−xi=p∑xi(1−p)n−∑xi.
ℓ(p)=(∑xi)lnp+(n−∑xi)ln(1−p).
dpdℓ=p∑xi−1−pn−∑xi=0⟹p^MLE=n∑xi=Xˉ.
Example 2: Normal(μ,σ2)
Xi∼N(μ,σ2) i.i.d.
L(μ,σ2)=∏i=1n2πσ21exp(−2σ2(xi−μ)2)=(2πσ2)−n/2exp(−2σ2∑(xi−μ)2).
ℓ(μ,σ2)=−2nln(2π)−2nlnσ2−2σ21∑(xi−μ)2.
For μ: ∂μ∂ℓ=σ21∑(xi−μ)=0⟹μ^MLE=Xˉ.
For σ2: ∂σ2∂ℓ=−2σ2n+2σ41∑(xi−μ)2=0⟹σ^MLE2=n1∑(xi−Xˉ)2.
Note: MLE divides by n (biased), MME gave the same.
Example 3: Poisson(λ)
Xi∼Poisson(λ) i.i.d.
L(λ)=∏i=1nxi!e−λλxi=∏xi!e−nλλ∑xi.
ℓ(λ)=−nλ+(∑xi)lnλ−ln(∏xi!).
dλdℓ=−n+λ∑xi=0⟹λ^MLE=n∑xi=Xˉ.
Example 4: Exponential(λ)
Xi∼Exp(λ) i.i.d.
L(λ)=∏i=1nλe−λxi=λne−λ∑xi.
ℓ(λ)=nlnλ−λ∑xi.
dλdℓ=λn−∑xi=0⟹λ^MLE=∑xin=Xˉ1.
4. MLE for Uniform(0,θ): A Special Case
fX(x;θ)=θ1, 0≤x≤θ.
L(θ)=θn1 for θ≥max(x1,…,xn), 0 otherwise.
L(θ) is maximised by the smallest possible θ that makes the data possible:
Note: No differentiation needed — this is a boundary problem.
5. Mermaid: MLE Flowchart
(Diagram)
6. Practice Questions
Q1 (Easy)
Find the MLE of p for Geometric(p) given X1,…,Xn i.i.d.
Full SolutionL(p)=∏p(1−p)xi−1=pn(1−p)∑xi−n.ℓ(p)=nlnp+(∑xi−n)ln(1−p).dpdℓ=pn−1−p∑xi−n=0⟹p^=∑xin=Xˉ1.
Q2 (Medium)
Find MLE for μ of N(μ,1) (known variance = 1).
Full Solutionℓ(μ)=−2nln(2π)−21∑(xi−μ)2.dμdℓ=∑(xi−μ)=0⟹μ^=Xˉ.
Q3 (Hard)
For Xi∼Uniform(−θ,θ), find MLE of θ.
Full SolutionfX(x;θ)=2θ1 for −θ≤x≤θ.L(θ)=(2θ)n1 for θ≥max(∣x1∣,…,∣xn∣).Maximising L means minimising θ, so θ^MLE=max(∣X1∣,…,∣Xn∣).
Next topic: Week 8.1: Properties of Estimators — Properties of estimators (bias, variance, consistency). Join Discord PreviousWeek 7.1: Point Estimation — Method of Moments (MME)NextWeek 8.1: Properties of Estimators