Maximum Likelihood and MAP Estimation

Suppose you observe the lifetimes of a hundred light bulbs. You want to predict how long the next one will last. You must pick a distribution family. Worse, you must pick specific numbers for its parameters. This all must come from finite noisy data alone. Maximum likelihood estimation (MLE) answers this by asking a deceptively simple question: which parameter values make the data you actually saw as probable as possible? This single principle underlies logistic regression, neural network training via cross-entropy loss, Gaussian mixture models, hidden Markov models, and much of classical statistics. MLE is the quiet engine behind almost every loss function in the formal learning problem, once you decide on a probabilistic model of your data. Minimizing squared error is MLE under Gaussian noise. Minimizing cross-entropy is MLE under a categorical model. Minimizing hinge-like surrogate losses often traces back to a likelihood argument in disguise. Understanding MLE means understanding why these losses look the way they do, not just how to code them. But MLE has a well-known failure mode. With little data or many parameters, it happily overfits. It assigns zero probability to anything unseen, and wild confidence to noise. Maximum a posteriori (MAP) estimation fixes this by folding in a prior belief over parameters. It then maximizes the resulting posterior instead. This turns out to be exactly regularization wearing a probabilistic disguise. A Gaussian prior gives ridge regression. A Laplace prior gives the lasso. This article builds MLE and MAP from first principles. It works through the algebra for concrete models. It gives pseudocode for the general optimization loop. It also traces the connection from priors to penalty terms. This way, "regularization strength" and "prior variance" become two names for the same knob.

Key takeaways
  • MLE picks parameters θ^\hat\theta that maximize the probability (or density) of the observed data under the model.
  • The log-likelihood turns products into sums, making optimization tractable via calculus or gradient methods.
  • MAP maximizes the posterior p(θ∣D)∝p(D∣θ) p(θ)p(\theta \mid D) \propto p(D \mid \theta)\,p(\theta), adding a prior term to the objective.
  • A Gaussian prior on weights yields exactly the ridge (L2) penalty; a Laplace prior yields the lasso (L1) penalty.
  • MLE is consistent and asymptotically efficient under regularity conditions, but can overfit badly in small-sample or high-dimensional regimes.
  • MAP with a fixed prior is a point estimate, not full Bayesian inference — it ignores posterior uncertainty.
The core insight

Maximum likelihood chooses parameters that best explain the data alone; MAP chooses parameters that best explain the data while respecting a prior belief, and that prior is mathematically identical to a regularizer.

The idea

Let data D={x1,…,xn}D = \{x_1, \dots, x_n\} be drawn i.i.d. from a distribution with density or mass function p(x∣θ)p(x \mid \theta), where θ∈Θ\theta \in \Theta is an unknown parameter vector. The likelihood function is the joint probability of the data viewed as a function of θ\theta with the data held fixed:

L(θ)=p(D∣θ)=∏i=1np(xi∣θ).L(\theta) = p(D \mid \theta) = \prod_{i=1}^n p(x_i \mid \theta).

The maximum likelihood estimator is

θ^MLE=arg⁡max⁡θ∈ΘL(θ)=arg⁡max⁡θ∏i=1np(xi∣θ).\hat\theta_{\text{MLE}} = \arg\max_{\theta \in \Theta} L(\theta) = \arg\max_\theta \prod_{i=1}^n p(x_i \mid \theta).

Because products of many small probabilities underflow numerically and are awkward to differentiate, one almost always works with the log-likelihood:

ℓ(θ)=log⁡L(θ)=∑i=1nlog⁡p(xi∣θ).\ell(\theta) = \log L(\theta) = \sum_{i=1}^n \log p(x_i \mid \theta).

Since log⁡\log is strictly increasing, maximizing ℓ(θ)\ell(\theta) gives the same maximizer as maximizing L(θ)L(\theta). In practice one minimizes the negative log-likelihood (NLL), −ℓ(θ)-\ell(\theta), turning estimation into a standard minimization problem compatible with gradient descent and other optimization machinery.

MAP estimation treats θ\theta itself as random, with a prior density p(θ)p(\theta) encoding belief before seeing data. Bayes' rule gives the posterior

p(θ∣D)=p(D∣θ) p(θ)p(D)∝p(D∣θ) p(θ),p(\theta \mid D) = \frac{p(D \mid \theta)\, p(\theta)}{p(D)} \propto p(D \mid \theta)\, p(\theta),

since p(D)p(D) does not depend on θ\theta. The MAP estimator maximizes this posterior:

θ^MAP=arg⁡max⁡θ  log⁡p(D∣θ)+log⁡p(θ)=arg⁡max⁡θ  [ℓ(θ)+log⁡p(θ)].\hat\theta_{\text{MAP}} = \arg\max_\theta \; \log p(D \mid \theta) + \log p(\theta) = \arg\max_\theta \; \left[ \ell(\theta) + \log p(\theta) \right].

Comparing the two objectives is the key insight: MAP is MLE plus an extra additive term log⁡p(θ)\log p(\theta). When p(θ)p(\theta) is a zero-mean Gaussian, log⁡p(θ)\log p(\theta) is (up to a constant) −λ∥θ∥22-\lambda \lVert \theta \rVert_2^2 — the ridge penalty. When p(θ)p(\theta) is a Laplace distribution, log⁡p(θ)\log p(\theta) becomes −λ∥θ∥1-\lambda \lVert \theta \rVert_1 — the lasso penalty. MAP is thus exactly regularized maximum likelihood, with the regularization strength determined by how concentrated the prior is around its mode.

How it works

Step 1 — choose a model family. Decide what distribution plausibly generated each data point: Bernoulli for binary labels, Gaussian for continuous noise, categorical/softmax for multi-class labels, Poisson for counts, and so on. This choice encodes assumptions and determines the eventual loss function.

Step 2 — write the log-likelihood. Expand ℓ(θ)=∑ilog⁡p(xi∣θ)\ell(\theta) = \sum_i \log p(x_i \mid \theta) using the chosen density.

Step 3 — optimize. For simple exponential-family models this can be done in closed form by setting ∇θℓ(θ)=0\nabla_\theta \ell(\theta) = 0 and solving. For most realistic models (logistic regression, neural networks, mixture models) there is no closed form, and one uses iterative numerical optimization: gradient ascent on ℓ(θ)\ell(\theta) (equivalently, gradient descent on the NLL), Newton's method, or specialized algorithms like Expectation-Maximization for latent-variable models.

Step 4 (for MAP) — add the prior term. Augment the objective with log⁡p(θ)\log p(\theta) before differentiating or before running gradient descent; this simply adds a penalty gradient ∇θlog⁡p(θ)\nabla_\theta \log p(\theta) to every update.

Step 5 — check second-order conditions. Verify (via the Hessian, or via convexity of the model class) that the stationary point found is indeed a maximum of the likelihood/posterior, not a saddle point or minimum — important for non-convex models like neural networks, where only local optima are guaranteed. ``` function FIT_MLE(data D = {x_1, ..., x_n}, model family p(x | theta), init theta_0): theta <- theta_0 repeat until convergence:

# negative log-likelihood and its gradient over the whole dataset g <- 0 # gradient accumulator, same shape as theta loss <- 0 for each x_i in D: loss <- loss - log p(x_i | theta) g <- g - grad_theta( log p(x_i | theta) ) theta <- theta - learning_rate g # gradient descent step on NLL return theta function FIT_MAP(data D, model family p(x | theta), prior p(theta), init theta_0): theta <- theta_0 repeat until convergence: g <- - grad_theta( log p(theta) ) # prior contributes a penalty gradient loss <- - log p(theta) for each x_i in D: loss <- loss - log p(x_i | theta) g <- g - grad_theta( log p(x_i | theta) ) theta <- theta - learning_rate g return theta ``` The two routines differ by exactly one term: the prior's negative log-density and its gradient. Everything else — the per-example likelihood gradient, the update rule, the convergence check — is identical. This is the precise sense in which "MAP equals regularized MLE."

Figure
From data to parameters: the MLE/MAP pipeline
Data D x₁, x₂, …, xₙ Model family p(x | θ) Prior (MAP only) p(θ) log-likelihood ℓ(θ) = Σᵢ log p(xᵢ|θ) (sum over data) Objective J(θ) MLE: ℓ(θ) MAP: ℓ(θ) + log p(θ) maximize J(θ) Optimizer gradient ascent / closed form θ̂

Complexity & correctness

Time complexity. For a dataset of nn points and a parameter vector of dimension dd, evaluating the log-likelihood and its gradient once costs O(nd)O(nd) for most standard models (linear/logistic regression, Gaussians with diagonal covariance), since each of the nn terms contributes an O(d)O(d) gradient computation. If the model requires a full covariance matrix (multivariate Gaussian MLE), computing and inverting the d×dd \times d covariance costs O(d3)O(d^3) in addition to the O(nd2)O(nd^2) needed to form it. Iterative optimization (gradient descent, Newton's method) multiplies the per-step cost by the number of iterations TT needed for convergence: total cost O(Tnd)O(Tnd) for gradient methods, or O(T(nd2+d3))O(T(nd^2 + d^3)) for Newton-type methods that use curvature. Closed-form MLEs (e.g., Gaussian mean and variance, or ordinary least squares via the normal equations) avoid the iteration factor TT entirely but may still pay O(d3)O(d^3) for a matrix inversion or decomposition. Stochastic gradient variants reduce the per-step cost to O(d)O(d) per example at the price of noisier updates and more steps to convergence — a classical statistical-computational tradeoff.

Space complexity. Storing the data is O(nd)O(nd); storing the parameter vector and its gradient is O(d)O(d); methods that use second-order information (the Hessian) require O(d2)O(d^2) space, which becomes prohibitive for large dd (e.g., deep networks), motivating first-order or quasi-Newton methods with limited memory.

Correctness of MLE — consistency. Under standard regularity conditions (identifiability of θ\theta, the true parameter θ∗\theta^* lying in the interior of Θ\Theta, smoothness of p(x∣θ)p(x\mid\theta)), the law of large numbers gives

1nℓ(θ)=1n∑ilog⁡p(xi∣θ)→  n→∞  Ex∼p(⋅∣θ∗)[log⁡p(x∣θ)].\frac{1}{n}\ell(\theta) = \frac{1}{n}\sum_i \log p(x_i \mid \theta) \xrightarrow{\;n\to\infty\;} \mathbb{E}_{x \sim p(\cdot\mid\theta^*)}[\log p(x \mid \theta)].

The right-hand side, as a function of θ\theta, is maximized uniquely at θ=θ∗\theta = \theta^*. This follows from Gibbs' inequality: for any two densities pp and qq,

Ex∼p[log⁡q(x)]≤Ex∼p[log⁡p(x)],\mathbb{E}_{x\sim p}[\log q(x)] \le \mathbb{E}_{x\sim p}[\log p(x)],

with equality iff p=qp = q almost everywhere — precisely the statement that the Kullback–Leibler divergence DKL(p ∥ q)≥0D_{\mathrm{KL}}(p \,\|\, q) \ge 0. So maximizing the empirical log-likelihood is, in the population limit, equivalent to minimizing DKL(p(⋅∣θ∗) ∥ p(⋅∣θ))D_{\mathrm{KL}}(p(\cdot\mid\theta^*) \,\|\, p(\cdot\mid\theta)) over θ\theta, whose unique minimizer is θ∗\theta^*. Hence θ^MLE→θ∗\hat\theta_{\text{MLE}} \to \theta^* in probability: MLE is consistent. Under further regularity, θ^MLE\hat\theta_{\text{MLE}} is also asymptotically normal and efficient, achieving the Cramér–Rao lower bound on variance among (asymptotically) unbiased estimators as n→∞n \to \infty.

Correctness of MAP — Bayesian justification. MAP is exactly correct as the mode of the true posterior p(θ∣D)p(\theta \mid D) by construction of Bayes' rule; no approximation is introduced beyond dropping the normalizing constant p(D)p(D), which does not affect the arg max. As n→∞n \to \infty, the likelihood term dominates a fixed prior (its curvature grows as O(n)O(n) while the prior's stays fixed), so θ^MAP→θ^MLE→θ∗\hat\theta_{\text{MAP}} \to \hat\theta_{\text{MLE}} \to \theta^* — the prior's influence vanishes asymptotically, a fact sometimes called the Bernstein–von Mises phenomenon.

Honest tradeoffs.

  • MLE can severely overfit when nn is small relative to dd: e.g., MLE variance estimates are biased low, and MLE for logistic regression with linearly separable data diverges to infinity.
  • MAP requires choosing a prior family and a strength; a badly mismatched prior introduces bias that does not vanish for finite nn, and choosing it via the data itself risks circularity (partially addressed by hierarchical/empirical Bayes methods, outside this scope).
  • MAP gives a single point estimate and, unlike full Bayesian posterior inference, does not quantify uncertainty about θ\theta — it reports the mode, not the shape, of the posterior.
  • For non-convex models (neural nets), neither MLE nor MAP is guaranteed to find the global optimum; gradient methods only guarantee convergence to a stationary point.

Worked example

Setup. You flip a possibly biased coin n=10n = 10 times and observe k=8k = 8 heads. Model each flip as Bernoulli(θ\theta), θ∈(0,1)\theta \in (0,1) being the probability of heads.

MLE derivation.

L(θ)=θk(1−θ)n−k,ℓ(θ)=klog⁡θ+(n−k)log⁡(1−θ).L(\theta) = \theta^k (1-\theta)^{n-k}, \qquad \ell(\theta) = k\log\theta + (n-k)\log(1-\theta).

Differentiate and set to zero:

ℓ′(θ)=kθ−n−k1−θ=0    ⟹    θ^MLE=kn=810=0.8.\ell'(\theta) = \frac{k}{\theta} - \frac{n-k}{1-\theta} = 0 \;\;\Longrightarrow\;\; \hat\theta_{\text{MLE}} = \frac{k}{n} = \frac{8}{10} = 0.8.

The second derivative ℓ′′(θ)=−k/θ2−(n−k)/(1−θ)2<0\ell''(\theta) = -k/\theta^2 - (n-k)/(1-\theta)^2 < 0 confirms a maximum.

MAP derivation with a Beta prior. Suppose you believe the coin is probably close to fair and encode this as a Beta(α,β)\mathrm{Beta}(\alpha, \beta) prior on θ\theta, with density p(θ)∝θα−1(1−θ)β−1p(\theta) \propto \theta^{\alpha-1}(1-\theta)^{\beta-1}. Take α=β=5\alpha = \beta = 5 (a fairly strong "near 0.5" belief, equivalent to having pre-observed 4 heads and 4 tails). The posterior is

p(θ∣D)∝θk+α−1(1−θ)n−k+β−1,p(\theta \mid D) \propto \theta^{k+\alpha-1}(1-\theta)^{n-k+\beta-1},

i.e. another Beta distribution (the Beta prior is conjugate to the Bernoulli likelihood). Its mode is

θ^MAP=k+α−1n+α+β−2=8+5−110+5+5−2=1218≈0.667.\hat\theta_{\text{MAP}} = \frac{k+\alpha-1}{n+\alpha+\beta-2} = \frac{8+5-1}{10+5+5-2} = \frac{12}{18} \approx 0.667.

Interpretation table:

QuantityValueReading
Raw data estimate (k/nk/n)0.800"80% heads, no prior belief"
Prior mode (α=β=5\alpha=\beta=5)0.500"I believed the coin was fair"
MAP estimate0.667Pulled from 0.8 toward 0.5
MAP with weak prior (α=β=1\alpha=\beta=1, uniform)0.800Uniform prior ⇒ MAP = MLE
MAP as n→∞n \to \infty (same k/nk/n ratio)→0.8\to 0.8Prior's pull vanishes with more data

This trace shows exactly how MAP behaves as advertised: with a flat (uniform) prior it collapses to MLE; with an informative prior it shrinks the estimate toward the prior mode, and that shrinkage weakens as the sample size grows — the hallmark of regularization. Note the pseudo-counts interpretation of the Beta prior: α−1\alpha - 1 acts like extra observed heads and β−1\beta-1 like extra observed tails, giving direct intuition for why α=β=5\alpha=\beta=5 pulls a small, unbalanced sample (88 heads out of 1010) noticeably toward 0.50.5.

Connection to regularized linear regression (second case). For linear regression yi=w⊤xi+εiy_i = w^\top x_i + \varepsilon_i with εi∼N(0,σ2)\varepsilon_i \sim \mathcal{N}(0,\sigma^2), the Gaussian log-likelihood is

ℓ(w)=−12σ2∑i(yi−w⊤xi)2+const,\ell(w) = -\frac{1}{2\sigma^2}\sum_i (y_i - w^\top x_i)^2 + \text{const},

so MLE for ww is exactly ordinary least squares: minimizing ∑i(yi−w⊤xi)2\sum_i (y_i - w^\top x_i)^2. Now place a Gaussian prior w∼N(0,τ2I)w \sim \mathcal{N}(0, \tau^2 I). Then

log⁡p(w)=−12τ2∥w∥22+const,\log p(w) = -\frac{1}{2\tau^2}\lVert w\rVert_2^2 + \text{const},

and the MAP objective becomes

arg⁡max⁡w  ℓ(w)+log⁡p(w)=arg⁡min⁡w  ∑i(yi−w⊤xi)2+σ2τ2∥w∥22,\arg\max_w \; \ell(w) + \log p(w) = \arg\min_w \; \sum_i (y_i - w^\top x_i)^2 + \frac{\sigma^2}{\tau^2}\lVert w \rVert_2^2,

which is precisely ridge regression with regularization strength λ=σ2/τ2\lambda = \sigma^2/\tau^2. A tighter prior (small τ2\tau^2, strong belief that weights are near zero) yields a larger λ\lambda — heavier shrinkage — exactly matching intuition.

Common pitfalls & traps

PitfallWhy it happensFix
Forgetting the n→n\to constant / normalizer when comparing likelihoods across models with different parameter countsRaw likelihood always increases (weakly) with more parametersUse AIC/BIC or held-out validation, not raw likelihood, for model comparison
Treating MAP as "the" Bayesian answerMAP is a single point (the mode), ignoring posterior spread/skewReport the full posterior or credible intervals when uncertainty matters
Using an improper or accidentally informative "flat" priorA prior that looks uninformative in one parameterization can be very informative in another (e.g., flat on θ\theta vs. flat on log⁡θ\log\theta)Choose priors thoughtfully in the parameterization that matches your actual belief
MLE diverging on separable data (logistic regression)The likelihood keeps increasing as ∥w∥→∞\lVert w\rVert \to \infty when classes are linearly separableAdd a prior/regularizer (MAP) or use early stopping
Confusing likelihood with probability of the parameterL(θ)L(\theta) is a function of θ\theta for fixed data, not a probability distribution over θ\theta — it need not integrate to 1 over θ\thetaRemember Bayes' rule is what turns L(θ)L(\theta) into a probability over θ\theta, via the prior and normalization
Non-concave log-likelihoods (mixture models, neural nets) trapping gradient ascent in local maximaThe objective is genuinely non-convexUse multiple restarts, better initialization, or EM-style algorithms suited to the structure

Pioneers & history

Origins · 1 minRonald Aylmer Fisher and how this was discovered
RA
Ronald Aylmer Fisher
1890–1962 · Statistics and genetics, early 20th century Britain

Fisher formalized maximum likelihood estimation as a general principle in the 1920s, proving its consistency and asymptotic efficiency, and introduced the concept of Fisher information that underlies the Cramér–Rao bound. He worked simultaneously as a statistician and geneticist, developing the mathematical foundations of experimental design and analysis of variance while at Rothamsted Experimental Station, work that would later become indispensable to statistical machine learning.

History
1763
— Bayes' theorem published posthumously, giving the mathematical basis for what becomes MAP estimation.
1922
— Ronald Fisher formalizes maximum likelihood as a general estimation principle and proves its asymptotic efficiency.
1946
— Fisher information and the Cramér–Rao lower bound are established as the benchmark for estimator efficiency.
1977
— Dempster, Laird, and Rubin publish the Expectation-Maximization algorithm, extending MLE to latent-variable models.
1990
s–2000s — MAP estimation with Gaussian and Laplace priors becomes standard justification for ridge regression and the lasso in statistical learning.

Where this matters

Nearly every standard training loss in modern machine learning is a negative log-likelihood in disguise. Training a neural network classifier with cross-entropy loss is exactly MLE under a categorical/softmax output model. Training a regression network with mean squared error is MLE under a Gaussian noise assumption. Weight decay, ubiquitous in deep learning frameworks, is MAP estimation with a Gaussian prior on the weights — an L2 penalty added to the loss. Speech recognition systems historically relied on MLE-trained hidden Markov models; modern language models are trained by maximizing the likelihood of the next token given context. Spam filters, medical diagnosis models, and recommendation systems built on logistic regression or naive Bayes are direct applications of MLE/MAP to Bernoulli and categorical likelihoods. In computational biology, MLE fits population-genetic models to sequence data; in finance, MLE estimates volatility parameters in stochastic models. Bayesian deep learning and probabilistic programming languages (Stan, PyMC, Pyro) build directly on the MAP-as-regularized-MLE view before extending to full posterior approximation via variational inference or MCMC — topics that assume this article's ideas as their starting point.

Ask the tutor: How does maximum likelihood estimation extend to models with latent variables, like Gaussian mixtures, via the Expectation-Maximization algorithm?

Is MLE just a special case of MAP?

Yes — MLE is MAP with a uniform (flat) prior over the parameter space, so that log⁡p(θ)\log p(\theta) is constant and contributes nothing to the arg max. More precisely, MLE is the limiting case of MAP as the prior's concentration around any particular value vanishes (infinite prior variance for a Gaussian prior, for instance). This is why the same optimization code can implement both: MAP training is MLE training with one extra penalty term added to the loss and its gradient. When people say "regularized maximum likelihood," they mean MAP.

Why does a Laplace prior give the L1 penalty and produce sparse solutions, while a Gaussian gives L2 and does not?

The Laplace density is p(θ)∝exp⁡(−λ∣θ∣)p(\theta) \propto \exp(-\lambda|\theta|), so log⁡p(θ)=−λ∣θ∣+const\log p(\theta) = -\lambda|\theta| + \text{const}, giving the L1 penalty directly in the MAP objective. The Laplace density has a sharp peak (non-differentiable point) at zero, which makes zero a genuinely attractive optimum for coordinates with weak signal, driving them to exactly zero — sparsity. The Gaussian density is smooth everywhere, including at zero, so its penalty λθ2\lambda\theta^2 has zero gradient at zero and merely shrinks weights toward zero without setting them there exactly.

Can MLE ever be a bad idea even with plenty of data?

With enough i.i.d. data and a well-specified, identifiable model, MLE is consistent and asymptotically efficient, so it is rarely "bad" asymptotically. Problems arise from model misspecification (the true data-generating process isn't in your model family, biasing the estimate no matter how much data you collect), from non-identifiability (multiple parameter values give the same likelihood, as in mixture model label-switching), and from computational issues in high dimensions (non-convex optimization landscapes in deep networks). In these cases more data doesn't fix the estimator; you need a better model, tighter identifiability constraints, or a different optimization strategy.

How is MAP different from full Bayesian inference?

MAP returns a single point — the mode (peak) of the posterior distribution p(θ∣D)p(\theta \mid D) — obtained by optimization. Full Bayesian inference characterizes the entire posterior distribution, capturing its spread, skewness, and any multimodality, typically via Markov Chain Monte Carlo sampling or variational approximation. MAP is much cheaper computationally (it's an optimization problem, not an integration problem) but throws away uncertainty information: two posteriors with the same mode but very different spreads give identical MAP estimates yet imply very different confidence in that estimate.

Why does MLE for logistic regression fail on linearly separable data?

If the training classes can be perfectly separated by a hyperplane, the logistic likelihood can be made arbitrarily close to 1 for every training point by scaling the weight vector ww toward infinity in the separating direction — the sigmoid outputs saturate toward 0 or 1 exactly where needed. The log-likelihood is monotonically increasing as ∥w∥→∞\lVert w \rVert \to \infty with no finite maximizer, so gradient ascent on the unregularized likelihood diverges. Adding any strictly informative prior (equivalently, any regularization term like L2) makes the objective concave with a bounded maximizer, fixing the issue — a direct practical case where MAP is not just "nicer" but necessary.

Does the choice of prior in MAP estimation ever get overridden by enough data?

Yes, under the same regularity conditions that make MLE consistent. As nn grows, the log-likelihood's curvature around its maximum grows proportionally to nn (each data point contributes independent curvature), while the log-prior's curvature stays fixed. The posterior mode is therefore pulled increasingly toward the MLE, and the influence of the prior's exact shape asymptotically vanishes — a fact related to the Bernstein–von Mises theorem, which further shows the posterior itself becomes approximately Gaussian centered near the MLE for large nn.

What's a quick way to remember which prior gives which penalty?

Match the prior's negative log-density shape to the familiar penalty formula. Gaussian: −log⁡p(θ)∝θ2-\log p(\theta) \propto \theta^2, a smooth bowl, giving the L2/ridge penalty and pure shrinkage. Laplace: −log⁡p(θ)∝∣θ∣-\log p(\theta) \propto |\theta|, a sharp V-shape, giving the L1/lasso penalty and sparsity-inducing shrinkage. Uniform/flat prior: −log⁡p(θ)-\log p(\theta) is constant, contributing nothing, recovering plain MLE. In general, whenever you see a penalty term added to a loss function, ask "what prior, if any, has this as its negative log-density?" — that's the MAP interpretation of the penalty.

Before this