Assume that we want to estimate an unobserved population parameter \theta on the basis of observations x. Let f be the
sampling distribution of x, so that f(x\mid\theta) is the probability of x when the underlying population parameter is \theta. Then the function: :\theta \mapsto f(x \mid \theta) \! is known as the
likelihood function and the estimate: :\hat{\theta}_{\mathrm{MLE}}(x) = \underset{\theta}{\operatorname{arg\,max}} \ f(x \mid \theta) \! is the maximum likelihood estimate of \theta. Now assume that a
prior distribution g over \theta exists. This allows us to treat \theta as a
random variable as in
Bayesian statistics. We can calculate the
posterior density of \theta using
Bayes' theorem: :\theta \mapsto f(\theta \mid x) = \frac{f(x \mid \theta) \, g(\theta)}{\displaystyle\int_{\Theta} f(x \mid \vartheta) \, g(\vartheta) \, d\vartheta} \! where g is density function of \theta, \Theta is the domain of g. The method of maximum a posteriori estimation then estimates \theta as the
mode of the posterior density of this random variable: :\begin{align} \hat{\theta}_{\mathrm{MAP}}(x) & = \underset{\theta}{\operatorname{arg\,max}} \ f(\theta \mid x) \\ & = \underset{\theta}{\operatorname{arg\,max}} \ \frac{f(x \mid \theta) \, g(\theta)} {\displaystyle\int_{\Theta} f(x \mid \vartheta) \, g(\vartheta) \, d\vartheta} \\ & = \underset{\theta}{\operatorname{arg\,max}} \ f(x \mid \theta) \, g(\theta). \end{align} \! The denominator of the posterior density (the
marginal likelihood of the model) is always positive and does not depend on \theta and therefore plays no role in the optimization. Observe that the MAP estimate of \theta coincides with the ML estimate when the prior g is uniform (i.e., g is a
constant function), which occurs whenever the prior distribution is taken as the reference measure, as is typical in function-space applications. In the context of
Bayes estimators, the MAP can be recovered as the minimizer of the Bayes risk with risk function : L(\theta, a) = \begin{cases} 0, & \text{if } |a-\theta| in the limit as c goes to 0, provided that the distribution of \theta is quasi-concave. Generally, however, a MAP estimator is not a Bayes estimator unless \theta is
discrete. == Computation ==