Skip to main content

Someone wanted to learn this too, so Grasp built them a personal learning path.

You can keep exploring this one or create your own

Maximum Likelihood and MAP Parameter Estimation

Hello. Previously, you used Bayes’ theorem to reason from evidence back to an underlying condition, then used expectation and variance to describe average behavior and uncertainty in ML systems. We now apply both ideas to parameter estimation: selecting model parameters that make observed data plausible.

The central distinction is simple but interview-critical:

  • Maximum likelihood estimation (MLE) uses the observed data alone.
  • Maximum a posteriori estimation (MAP) combines the data with an explicit prior belief about plausible parameter values.

By the end, you should be able to set up an MLE objective, derive common estimates for Bernoulli and Gaussian models, and explain MAP as likelihood plus a prior-driven regularization term.


Likelihood: treating the data as fixed and parameters as candidates

Suppose a model has unknown parameters , and you have observed a dataset:

A probabilistic model specifies : how likely an observation would be if the parameter were .

For a fixed candidate parameter , the likelihood is:

Under the usual independent and identically distributed assumption:

The expression looks like a probability, but the role is different:

  • In , the parameter is held fixed and the data are random.
  • In likelihood-based estimation, the observed dataset is fixed and we compare candidate parameter values by how well they explain it.

For continuous models, this is technically a density, not the probability of exactly observing the data. That does not affect estimation: compare relative likelihoods under the same model.

A practical caveat matters in ML evaluation. The factorization above assumes independent observations. Consecutive autonomous-driving frames, requests from the same user session, or predictions from the same trip are correlated. You can still use likelihood-based training models, but you should be clear about the modeling assumption and avoid treating highly correlated frames as fully independent evidence when reporting uncertainty.

10-315 Notes Maximum Likelihood Estimation

Read the CMU 10-315 notes to consolidate likelihood, log-likelihood, and the Bernoulli and Gaussian MLE derivations used throughout ML.

In Section 2, “Likelihood” (pp. 2–5), focus on the iid assumption and the resulting product form. Then read Section 3, “Maximum Likelihood Estimation,” especially Section 3.2, “Log-likelihood,” through why logs help. In Section 3.5.2, “Bernoulli” (p. 9), follow the coin derivation; then in Section 3.5.4, “Gaussian” (pp. 11–12), read from the Gaussian setup. Focus on how maximizing a likelihood becomes minimizing a familiar loss.


MLE: choose parameters that make the observed dataset most plausible

The MLE is the parameter value that maximizes likelihood:

Directly multiplying many probabilities is numerically fragile: products of values smaller than one rapidly underflow to zero. Instead, take the logarithm. Since the logarithm is strictly increasing, it preserves the parameter value that maximizes the objective:

For i.i.d. data, the log converts a product into a sum:

In ML implementations, we usually minimize the negative log-likelihood:

This is not merely a theoretical reformulation. It is the source of familiar training losses:

  • Gaussian observation noise gives squared-error loss.
  • Bernoulli outputs give binary cross-entropy.
  • Categorical outputs give multiclass cross-entropy.

Bernoulli MLE: the empirical success rate

Let , where might mean “the detector correctly recognizes a pedestrian in this sampled scenario.” Assume:

where is the unknown probability of success.

If the dataset contains ones and zeros, with , then:

The log-likelihood is:

Differentiate and set the derivative to zero:

Solving gives:

So the MLE of a Bernoulli probability is the observed fraction of successes.

If a perception detector correctly recognizes out of instances in a narrow scenario slice, MLE estimates:

This estimate exactly matches the data. That is its strength and, with scarce data, its weakness. If the same slice had one example and the detector succeeded, MLE would estimate . A perfect probability estimate based on one example should make you uneasy.

Gaussian MLE: the sample mean

Suppose latency measurements or continuous residuals follow a Gaussian model with known variance :

The negative log-likelihood, ignoring terms that do not depend on , is:

Therefore, maximizing Gaussian likelihood is equivalent to minimizing the sum of squared residuals:

Its solution is:

This connects probabilistic assumptions to regression: if targets are conditionally Gaussian around a model prediction, minimizing mean squared error is MLE.

One useful distinction from the previous lesson: if both and are unknown, the Gaussian MLE variance uses denominator :

The familiar sample variance is a different estimator designed to be unbiased for population variance under a sampling interpretation. MLE optimizes likelihood; unbiasedness is not its objective.


MAP: use data, but also state what you believed before seeing it

MLE asks:

Which parameter makes the observed data most likely?

MAP asks:

Which parameter is most probable after combining the data with a prior belief?

Bayes’ rule gives the relationship:

The three relevant pieces are:

  • : likelihood, how well parameter explains the data;
  • : prior, beliefs about plausible parameter values before seeing this dataset;
  • : posterior, updated beliefs after combining the two.

MAP selects the mode of the posterior:

The evidence term is constant with respect to , so it does not affect the maximizing value:

Taking logs gives the form worth remembering:

Equivalently, as a minimization objective:

MAP is therefore MLE plus a log-prior term.

What are Maximum Likelihood (ML) and Maximum a posteriori (MAP)? ("Best explanation on YouTube")

Watch “What are Maximum Likelihood (ML) and Maximum a posteriori (MAP)?” by Iain Explains Signals, Systems, and Digital Comms. It gives a visual explanation of the conditional direction in MLE and shows exactly how a prior reweights likelihood in MAP.

Watch MLE intuition, focusing on the difference between observing a measurement and varying candidate parameter values. Then watch the MAP derivation, where Bayes’ rule turns posterior maximization into likelihood times prior. Finish with the comparison, especially the point that a uniform prior makes MAP and MLE identical.


A concrete MAP calculation: smoothing a Bernoulli estimate

For a Bernoulli parameter , a natural prior is a Beta distribution:

Ignoring the normalizing constant, the prior density has the form:

The prior can express, for example, a belief that probabilities near are more plausible than extreme values before a small scenario slice has been evaluated.

With observed successes and failures, the posterior is:

When the posterior is interior, meaning both posterior shape parameters exceed one, its MAP estimate is:

Suppose an evaluation slice contains correct detections and failures:

MLE is:

Now use a symmetric prior:

The MAP estimate becomes:

The data favor , while the prior favors values nearer . MAP balances these sources of information, giving .

Four plots compare a prior favoring a roughly fair coin, a likelihood whose MLE peaks at a \(0.70\) heads probability, and the resulting posterior whose MAP peak is shifted to about \(0.67\). The final panel overlays the prior, scaled likelihood, and posterior to show why MAP lies between the prior preference and the data-only MLE.

The amount of movement toward the prior depends on prior strength relative to the amount of data:

  • With little data, a meaningful prior can substantially influence MAP.
  • With abundant representative data, the likelihood dominates.
  • With a uniform prior, MAP and MLE coincide.

This last fact follows immediately: if is constant over the feasible parameter range, multiplying likelihood by that constant does not change its maximizer.


MAP as regularization

The connection between MAP and regularization is a frequent ML interview topic.

Assume a linear model with Gaussian noise:

The negative log-likelihood is, up to constants:

Now place an independent zero-mean Gaussian prior on the weights:

The negative log-prior is, up to constants:

The MAP objective is therefore:

This is ridge regression. A Gaussian prior centered at zero corresponds to an penalty that discourages large weights.

Similarly, independent Laplace priors lead to an penalty, which is the MAP interpretation behind lasso-style sparsity.

The concise interview statement is:

Regularization can be interpreted as a log-prior. Standard MLE minimizes negative log-likelihood, while MAP minimizes negative log-likelihood plus a penalty induced by prior beliefs about parameters.

Be precise about what this does not imply:

  • A regularizer is only a Bayesian prior if it corresponds to a proper probabilistic prior under the stated model.
  • A MAP estimate is one point estimate, not the complete posterior distribution.
  • MAP is not necessarily the posterior mean. For skewed or multimodal posteriors, mean and mode can differ materially.

Choosing between MLE and MAP in practice

Question MLE MAP
Objective Maximize Maximize
Uses a prior? No Yes
Optimization form Maximize log-likelihood Maximize log-likelihood plus log-prior
Small-data behavior Can fit noise or produce extreme estimates Can stabilize estimates if the prior is justified
Large-data behavior Data dominates Usually converges toward MLE with a fixed, well-behaved prior
Common ML connection Cross-entropy and squared-error training Regularization, smoothing, weight decay

For production ML, priors must be defensible. A prior could come from physics, known sensor behavior, historical versions of a system, or carefully separated historical datasets. It should not be a convenient way to force a preferred result.

For example, a prior based on the aggregate performance of an existing perception model might stabilize estimates for a rare night-rain-pedestrian slice. But if the new model architecture or data collection process changed substantially, that historical prior may no longer be appropriate. The system-level issue is not only mathematical: it is also a data lineage and distribution-shift question.


An interview-ready explanation

A compact but rigorous response could sound like this:

“MLE chooses parameters that maximize the likelihood of the observed data. Under independent samples, I maximize the sum of per-example log-likelihoods, or equivalently minimize negative log-likelihood. For a Bernoulli model, that gives the observed positive fraction; for a Gaussian model with fixed variance, it gives the sample mean.

MAP instead maximizes the posterior over parameters. By Bayes’ rule, that is likelihood times prior, so in log space it is the MLE objective plus a log-prior term. A Gaussian prior on weights produces regularization, so ridge regression has a MAP interpretation. MAP is especially useful when data are limited and the prior is justified; with a uniform prior, it reduces to MLE.”


Key takeaways

MLE estimates parameters using data alone:

For i.i.d. observations, maximize the log-likelihood instead:

For a Bernoulli model, MLE is the observed success rate:

MAP incorporates a prior:

Conceptually, MAP is MLE with an explicit, probabilistically grounded regularization term. It can improve small-data estimates, but only when its prior assumptions are appropriate.

Next, you will move from parameter estimates to uncertainty around estimates by constructing and interpreting confidence intervals for model or experiment metrics.

Can't find a good explanation? Sign up and we'll make it for you

Sign up