Maximum likelihood estimation

Also known as: MLE

On this page 7

Maximum likelihood estimation (MLE) is a method for estimating the parameters of a statistical model by choosing the values that make the observed data most probable under that model. It is the default fitting principle for probabilistic models in machine learning and artificial intelligence, from simple Gaussian fits to logistic regression, hidden Markov models and large neural language models.

MLE treats the parameters as fixed but unknown quantities and the data as given. It defines a likelihood function over parameter values and searches for its maximum, either in closed form for simple models or by numerical optimization for complex ones.

How maximum likelihood estimation works

Given independent observations x1 to xn and a model with density p(x | θ), the likelihood L(θ) is the product of p(xi | θ) over all observations. The MLE is the parameter value θ̂ that maximizes this product. Because products of many small probabilities underflow numerically, practitioners maximize the log-likelihood, which turns the product into a sum and has the same maximizer.

For many textbook models, setting the derivative of the log-likelihood to zero gives an analytic solution. For most modern models no closed form exists, so the estimate is found with gradient-based optimization, Newton-type methods or the expectation-maximization (EM) algorithm when latent variables are present.

ModelParameterMaximum likelihood estimate
BernoulliSuccess probability pProportion of successes
GaussianMean μSample mean
GaussianVariance σ²Mean squared deviation, divided by n
PoissonRate λSample mean of counts
CategoricalClass probabilitiesRelative frequency of each class
ExponentialRate λReciprocal of the sample mean
Closed-form MLE results for common distributions

Minimizing the negative log-likelihood is the same task stated as a loss. This is why cross-entropy loss in classifiers and next-token prediction in language models are maximum likelihood training, and why mean squared error corresponds to MLE under Gaussian noise.

Statistical properties of the estimator

MLE is popular because, under standard regularity conditions, it has strong large-sample guarantees. These conditions include a correctly specified model, identifiable parameters and a parameter space in which the true value is not on the boundary.

PropertyMeaningCaveat
ConsistencyEstimate converges to the true value as n growsRequires a correctly specified model
Asymptotic normalityErrors become approximately GaussianCan be poor for small samples
Asymptotic efficiencyVariance reaches the Cramér-Rao boundHolds only in the large-sample limit
InvarianceMLE of g(θ) equals g(θ̂)Unbiasedness is not preserved
Possible biasFinite-sample estimates can be biasedGaussian variance divides by n, not n − 1
Key properties and their practical meaning

The curvature of the log-likelihood at its peak, measured by the Fisher information, determines how precise the estimate is. Its inverse gives approximate standard errors and confidence intervals, which is the basis of the Wald test and of many classical inference procedures.

MLE compared with Bayesian estimation

MLE is a frequentist point estimate, while the neighboring methods in the probabilistic toolbox add prior knowledge or return full distributions. The choice affects how uncertainty is represented and how the method behaves on small datasets.

MethodWhat it returnsRole of priorTypical cost
Maximum likelihood estimationSingle best parameter valueNoneOne optimization
Maximum a posteriori estimationMode of the posteriorActs as a regularizerOne optimization
Full Bayesian inferenceEntire posterior distributionExplicit and essentialSampling or variational inference
MLE, MAP and full Bayesian inference

With a uniform prior, maximum a posteriori estimation reduces to MLE. Conversely, common regularizers have Bayesian readings: L2 weight decay corresponds to a Gaussian prior and L1 to a Laplace prior. As the dataset grows, the likelihood dominates the prior and all three methods tend to agree.

Optimization in practice

Real models rarely allow analytic solutions, so implementation details strongly affect results. The log-likelihood of deep networks and mixture models is non-convex, which means optimizers may stop at local maxima or saddle points.

  • Work in log space and use log-sum-exp to avoid numerical underflow.
  • Use EM for latent variables, as in Gaussian mixtures and the Baum-Welch algorithm.
  • Run several random restarts when the likelihood surface has multiple peaks.
  • Use stochastic gradients on mini-batches for large datasets.
  • Check convergence with the log-likelihood on held-out data, not only training data.

Some likelihoods are unbounded. In a Gaussian mixture, a component can collapse onto a single point and drive its variance toward zero, so the likelihood grows without limit. Practitioners prevent this degenerate solution with variance floors, priors or careful initialization.

Large generative models are also trained by maximum likelihood. A language model maximizes the log-probability of each next token given the preceding context, summed over billions of tokens. Training metrics such as perplexity are simply the exponentiated average negative log-likelihood, so a lower perplexity means the model assigns higher likelihood to held-out text. Fine-tuning stages that follow, such as preference optimization, deliberately depart from pure likelihood objectives.

Limitations and common mistakes

MLE is only as good as the model it is applied to. Its most serious weakness is overfitting with small samples or many parameters, because the estimator fits the observed data as closely as possible without any penalty for complexity.

ProblemCauseRemedy
OverfittingToo many parameters for the dataRegularization, MAP or more data
Zero probabilitiesUnseen categories get probability zeroAdditive smoothing or a Dirichlet prior
Model misspecificationWrong distributional assumptionDiagnostics and robust likelihoods
OverconfidencePoint estimate ignores uncertaintyBayesian methods or bootstrapping
Separation in classificationPerfectly separable classesPenalized likelihood
Typical problems and remedies

A frequent misconception is that the likelihood is a probability distribution over parameters. It is not: the likelihood does not integrate to one over θ and cannot be read as the probability that a parameter value is true. That interpretation requires a prior and the posterior distribution.

The simple explanation

Maximum likelihood estimation is a way to pick the settings of a model. You try possible settings. For each one, you ask how likely your actual data would be. You keep the setting that makes your data look least surprising.

Imagine a coin that lands heads 7 times in 10 flips. Which bias explains this best? A coin with a 70 percent chance of heads does. That guess is the maximum likelihood estimate. It is simple and usually works well. With very little data, however, it can trust the data too much.

How it is used in practice

A data science team at an online retailer wants to predict whether a visitor will complete a purchase. They fit a logistic regression model with features such as session length, number of product views and device type, using about 500,000 past sessions.

Training minimizes binary cross-entropy, which is the negative log-likelihood of the observed purchase outcomes. The optimizer converges in a few seconds, and the team uses the Fisher information matrix to obtain standard errors for each coefficient, which shows that device type has a small but statistically reliable effect.

When they later add hundreds of sparse product-category features, the validation log-likelihood drops while the training log-likelihood keeps rising. The team switches to an L2-penalized fit, equivalent to MAP estimation with a Gaussian prior, and recovers better calibrated purchase probabilities on held-out data.