Choosing parameters by asking which data were most likely
Maximum likelihood estimation answers a single question: given a family of distributions parameterised by theta, which value of theta makes the observed data most probable? The likelihood function is the probability of the data viewed as a function of the parameter rather than of the data, and the estimate is the value that peaks it. The logic is intuitive enough to state in one sentence, and it produces estimators with strong long-run properties across an enormous range of models.
That reach is the reason the method dominates. Linear regression under normal errors, logistic regression, Poisson models, hidden Markov models, and the cross-entropy loss that trains every classifier are all maximum likelihood in disguise. Once you can write down the probability of the data given parameters, you have specified the loss; optimisation does the rest. Likelihood also supplies a coherent framework for comparing models through likelihood-ratio tests and information criteria, which turn questions about fit into arithmetic on a single scalar.
From products to sums: the log-likelihood
For independent observations the likelihood is a product of individual density terms, and products are numerically dreadful — thirty density values below one already underflow a float. Taking logarithms converts the product into a sum, preserves the location of the maximum because the logarithm is strictly increasing, and usually turns a gnarly expression into something differentiable term by term. Every optimiser in practice therefore receives the negative log-likelihood, minimised rather than maximised, because optimisers are written to descend.
The transformation has a statistical life of its own. Sums of log-terms are what the central limit theorem is about, so the log-likelihood itself is approximately quadratic near its peak for large samples. That quadratic approximation produces the familiar parabola whose curvature is the Fisher information, whose width gives the standard error, and whose departure from parabola signals that asymptotic normality may not yet have arrived. Reading a log-likelihood plot is therefore a direct diagnostic of how much the large-sample theory can be trusted.
Closed-form estimates for familiar distributions
Several common models admit an estimator you can write down, and each is worth knowing as a sanity check on numerical output. For a normal distribution the mean estimate is the sample mean and the variance estimate is the average squared deviation — dividing by n rather than n minus one, which makes the maximum likelihood variance slightly biased downward but consistent. For a Poisson the rate estimate is the sample mean. For a Bernoulli it is the success proportion. For an exponential distribution it is one over the sample mean.
The pattern behind these results is the same every time: write the log-likelihood, differentiate with respect to the parameter, set the derivative to zero, and solve. When no solution exists in closed form, the equation itself is still useful — it is the estimating equation that numerical methods solve — and for exponential families the log-likelihood is concave, so any stationary point is the global maximum.
| Distribution | Parameter | Maximum likelihood estimate | Note |
|---|---|---|---|
| Normal | Mean | Sample mean | Unbiased and efficient |
| Normal | Variance | Average squared deviation | Divides by n, so biased downward |
| Poisson | Rate | Sample mean | Closed form, unbiased |
| Bernoulli | Success probability | Successes over trials | Closed form, unbiased |
| Exponential | Rate | One over the sample mean | Closed form, asymptotically unbiased |
The score function and numerical optimisation
The score function is the derivative of the log-likelihood with respect to the parameter, and setting it to zero is the defining equation of the maximum likelihood estimate. Its expected value is zero at the true parameter, which is what makes it a valid estimating equation, and its variance is precisely the Fisher information — a pleasing identity that connects estimation, curvature, and precision in one statement.
When the score equation has no closed-form solution, optimisation takes over. Gradient ascent works but converges slowly near the peak; Newton's method uses the second derivative and converges quadratically once close, which is why it is the workhorse for generalized linear models; quasi-Newton methods such as BFGS estimate the curvature and need only first derivatives. Every one of them benefits from the concavity that exponential families provide, because then a local optimum is the global one and the starting value hardly matters. Poor initialisation is far more dangerous in models that are not concave, such as mixtures and multi-layer networks, where it can strand the optimiser in a flat region or a bad local mode.
Fisher information and the efficiency floor
Fisher information measures how much each observation tells you about the parameter. Formally it is the negative expected second derivative of the log-likelihood, which is the curvature of the log-likelihood at the truth: a sharply peaked likelihood means the data pin the parameter down tightly, and a flat one means many parameter values remain plausible. The square root of the inverse information is the asymptotic standard error of the maximum likelihood estimate.
Its most famous consequence is the Cramér-Rao lower bound, which states that no unbiased estimator can have variance below the reciprocal of the Fisher information. Since maximum likelihood attains that bound asymptotically, the method is efficient in the large-sample sense, and the bound itself gives a lower limit on how precisely any procedure could ever measure the parameter. Practically, the information is also what powers Wald tests and confidence intervals, and it degrades when parameters become weakly identified — flat likelihoods, sparse data, or confounded predictors all show up as small information and correspondingly large standard errors.
Fitting models by maximum likelihood in Python
import numpy as np
from scipy import stats, optimize
def normal_nll(params, data):
mu, log_sigma = params
sigma = np.exp(log_sigma)
return float(np.sum(0.5 * np.log(2 * np.pi * sigma ** 2)
+ 0.5 * ((data - mu) / sigma) ** 2))
def poisson_nll(log_lambda, counts):
lam = np.exp(log_lambda[0])
return float(np.sum(lam - counts * log_lambda[0]
+ np.array([np.sum(np.log(np.arange(1, c + 1)))
if c > 0 else 0.0 for c in counts])))
rng = np.random.default_rng(29)
sample = rng.normal(42.0, 6.5, 300)
res = optimize.minimize(normal_nll, x0=[0.0, 0.0], args=(sample,),
method="BFGS")
mu_hat, sigma_hat = res.x[0], np.exp(res.x[1])
print(f"MLE mean = {mu_hat:.3f} (true 42.0), "
f"MLE sd = {sigma_hat:.3f} (true 6.5)")
print(f"MLE variance divisor n : {np.var(sample):.3f}")
print(f"unbiased divisor n - 1 : {np.var(sample, ddof=1):.3f}")
counts = rng.poisson(lam=3.7, size=200)
res_p = optimize.minimize(poisson_nll, x0=[np.log(1.0)], args=(counts,),
method="BFGS")
print(f"Poisson rate MLE = {np.exp(res_p.x[0]):.3f} "
f"(sample mean {counts.mean():.3f})")
The optimiser recovers both parameters to three decimal places, and the two variance lines make the bias concrete: the maximum likelihood divisor is visibly smaller than the unbiased one, exactly as the theory predicts. The Poisson fit reproduces the sample mean, confirming the closed-form result numerically.
The second block computes Fisher information and compares the resulting standard errors against an empirical one from repeated sampling.
import numpy as np
def fisher_information_normal(mu, sigma, n):
"""Curvature of the log-likelihood for a normal mean and variance."""
i_mu = n / sigma ** 2
i_sigma2 = n / (2 * sigma ** 4)
return i_mu, i_sigma2
def asymptotic_se(n, sigma):
i_mu, i_sigma2 = fisher_information_normal(0, sigma, n)
return np.sqrt(1 / i_mu), np.sqrt(1 / i_sigma2)
def sampling_study(n=60, sigma=5.0, repeats=4000, seed=0):
rng = np.random.default_rng(seed)
estimates = rng.normal(10.0, sigma, size=(repeats, n)).mean(axis=1)
return estimates.mean(), estimates.std(ddof=1)
emp_mean, emp_sd = sampling_study()
theory_se, _ = asymptotic_se(60, 5.0)
print(f"empirical sd of mean estimates = {emp_sd:.4f}")
print(f"Fisher information based se = {theory_se:.4f}")
print("var estimate >= 1 / I(theta)?",
theory_se ** 2 >= 1 / (60 / 5.0 ** 2))
The empirical spread of the estimates matches the information-based standard error to three digits, which is the Cramér-Rao bound behaving exactly as advertised: no estimator using the same data could do better on average.
Likelihood pitfalls
Common Mistakes
Confusing likelihood with probability
Fix: Probability sums to one over outcomes; likelihood is a function of parameters and need not integrate to one.
Maximising the product form directly
Fix: Work with the log-likelihood to avoid underflow and to get additive, better-conditioned gradients.
Quoting the maximum likelihood variance with an n divisor as unbiased
Fix: Divide by n minus one for an unbiased estimate, or state that the maximum likelihood version is biased downward.
Reporting Wald intervals on a visibly flat likelihood
Fix: Check curvature; use a likelihood-ratio or profile interval when information is low.
Trusting a local optimum in a non-concave model
Fix: Multi-start initialisation or a profile scan is required before the estimate means anything.
Comparing models with different data via likelihood alone
Fix: Use likelihood-ratio tests for nested models and AIC or BIC, which penalise complexity.
MLE essentials
Where to go next
- Point Estimation compares likelihood with the method of moments.
- Properties of Estimators covers unbiasedness, consistency, and sufficiency.
- Logistic Regression Statistics applies likelihood estimation to a model with no closed form.
- Bayesian Regression shows the Bayesian counterpart to point estimation.