# Maximum a posteriori

In statistics, the method of maximum a posteriori (MAP, or posterior mode) estimation can be used to obtain a point estimate of an unobserved quantity on the basis of empirical data. It is closely related to Fisher's method of maximum likelihood (ML), but employs an augmented optimization objective which incorporates a prior distribution over the quantity one wants to estimate. MAP estimation can therefore be seen as a regularization of ML estimation.

## Introduction

Assume that we want to estimate an unobserved population parameter ${\displaystyle \theta }$ on the basis of observations ${\displaystyle x}$. Let ${\displaystyle f}$ be the sampling distribution of ${\displaystyle x}$, so that ${\displaystyle f(x|\theta )}$ is the probability of ${\displaystyle x}$ when the underlying population parameter is ${\displaystyle \theta }$. Then the function

${\displaystyle \theta \mapsto f(x|\theta )\!}$

is known as the likelihood function and the estimate

${\displaystyle {\hat {\theta }}_{\mathrm {ML} }(x)=\arg \max _{\theta }f(x|\theta )\!}$

as the maximum likelihood estimate of ${\displaystyle \theta }$.

Now assume that a prior distribution ${\displaystyle g}$ over ${\displaystyle \theta }$ exists. This allows us to treat ${\displaystyle \theta }$ as a random variable as in Bayesian statistics. Then the posterior distribution of ${\displaystyle \theta }$ is as follows:

${\displaystyle \theta \sim {\frac {f(x|\theta )\,g(\theta )}{\displaystyle \int _{\Theta }f(x|\theta ')\,g(\theta ')\,d\theta '}}\!}$

where ${\displaystyle g}$ is density function of ${\displaystyle \theta }$, ${\displaystyle \Theta }$ is the domain of ${\displaystyle g}$. This is a straightforward application of Bayes' theorem.

The method of maximum a posteriori estimation then estimates ${\displaystyle \theta }$ as the mode of the posterior distribution of this random variable:

${\displaystyle {\hat {\theta }}_{\mathrm {MAP} }(x)=\arg \max _{\theta }{\frac {f(x|\theta )\,g(\theta )}{\displaystyle \int _{\Theta }f(x|\theta ')\,g(\theta ')\,d\theta '}}=\arg \max _{\theta }f(x|\theta )\,g(\theta )\!}$

The denominator of the posterior distribution does not depend on ${\displaystyle \theta }$ and therefore plays no role in the optimization. Observe that the MAP estimate of ${\displaystyle \theta }$ coincides with the ML estimate when the prior ${\displaystyle g}$ is uniform (that is, a constant function).

MAP estimates can be computed in several ways:

1. Analytically, when the mode(s) of the posterior distribution can be given in closed form. This is the case when conjugate priors are used.
2. Via numerical optimization such as the conjugate gradient method or Newton's method. This usually requires first or second derivatives, which have to be evaluated analytically or numerically.
3. Via a modification of an expectation-maximization algorithm. This does not require derivatives of the posterior density.

While MAP estimation shares the use of a prior distribution with Bayesian statistics, it is not generally seen as a Bayesian method. This is because MAP estimates are point estimates, whereas Bayesian methods are characterized by the use of distributions to summarize data and draw inferences. Bayesian methods tend to report the posterior mean or median together with posterior intervals, rather than the posterior mode. This is especially so when the posterior distribution does not have a simple analytic form: in this case, the posterior distribution can be simulated using Markov chain Monte Carlo techniques, while optimization to find its mode(s) may be difficult or impossible.

## Example

Suppose that we are given a sequence ${\displaystyle (x_{1},\dots ,x_{n})}$ of IID ${\displaystyle N(\mu ,\sigma _{v}^{2})}$ random variables and an a priori distribution of ${\displaystyle \mu }$ is given by ${\displaystyle N(0,\sigma _{m}^{2})}$. We wish to find the MAP estimate of ${\displaystyle \mu }$.

The function to be maximized is then given by

${\displaystyle \pi (\mu )L(\mu )={\frac {1}{\sqrt {2\pi \sigma _{m}}}}\exp \left(-{\frac {1}{2}}\left({\frac {\mu }{\sigma _{m}}}\right)^{2}\right)\prod _{j=1}^{n}{\frac {1}{\sqrt {2\pi \sigma _{v}}}}\exp \left(-{\frac {1}{2}}\left({\frac {x_{j}-\mu }{\sigma _{v}}}\right)^{2}\right),}$

which is equivalent to minimizing ${\displaystyle \mu }$ in the following

${\displaystyle \sum _{j=1}^{n}\left({\frac {x_{j}-\mu }{\sigma _{v}}}\right)^{2}+\left({\frac {\mu }{\sigma _{m}}}\right)^{2}.}$

Thus, we see that the MAP estimator for μ is given by

${\displaystyle {\hat {\mu }}_{MAP}={\frac {\sigma _{m}^{2}}{n\sigma _{m}^{2}+\sigma _{v}^{2}}}\sum _{j=1}^{n}x_{j}.}$

The case of ${\displaystyle \sigma _{m}\to \infty }$ is called a non-informative prior and leads to an ill-defined a priori probability distribution; in this case ${\displaystyle {\hat {\mu }}_{MAP}\to {\hat {\mu }}_{MLE}.}$