{"id":413,"date":"2024-07-22T20:06:39","date_gmt":"2024-07-22T11:06:39","guid":{"rendered":"https:\/\/mp-superkler.com\/?p=413"},"modified":"2024-07-23T07:46:45","modified_gmt":"2024-07-22T22:46:45","slug":"maximum-a-posteriori-map-estimation","status":"publish","type":"post","link":"https:\/\/mp-superkler.com\/?p=413","title":{"rendered":"Maximum a Posteriori (MAP) estimation"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Maximum a Posteriori (MAP) estimation is a popular method in Bayesian statistics to estimate an unknown quantity. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">MAP Estimation<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">MAP estimation aims to find the mode of the posterior distribution. Given a set of observed data \\( \\mathbf{X} = {x_1, x_2, \\ldots, x_n} \\) and a parameter \\( \\theta \\) to be estimated, the MAP estimate is defined as:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$$ \\hat{\\theta}{\\text{MAP}} = \\arg\\max{\\theta} P(\\theta \\mid \\mathbf{X}) $$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using Bayes&#8217; theorem, the posterior distribution \\( P(\\theta \\mid \\mathbf{X}) \\) can be expressed as:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$$ P(\\theta \\mid \\mathbf{X}) = \\frac{P(\\mathbf{X} \\mid \\theta) P(\\theta)}{P(\\mathbf{X})} $$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Since \\( P(\\mathbf{X}) \\) is a constant with respect to \\( \\theta \\), the MAP estimate simplifies to:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$$ \\hat{\\theta}{\\text{MAP}} = \\arg\\max{\\theta} P(\\mathbf{X} \\mid \\theta) P(\\theta) $$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thus, we need to maximize the product of the likelihood \\( P(\\mathbf{X} \\mid \\theta) \\) and the prior \\( P(\\theta) \\).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Detailed Proof<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s consider the logarithm of the posterior distribution for computational convenience. The logarithm is a monotonic function, so the value of \\( \\theta \\) that maximizes the posterior will also maximize the log-posterior:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$$\\hat{\\theta}{\\text{MAP}} = \\arg\\max{\\theta} \\log P(\\mathbf{X} \\mid \\theta) + \\log P(\\theta)$$<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Likelihood \\( P(\\mathbf{X} \\mid \\theta) \\)<\/strong>: The likelihood function is the probability of the observed data given the parameter \\( \\theta \\). <br>$$ P(\\mathbf{X} \\mid \\theta) = \\prod_{i=1}^{n} P(x_i \\mid \\theta)<br>$$ Taking the logarithm, we get: <br>$$\\log P(\\mathbf{X} \\mid \\theta) = \\sum_{i=1}^{n} \\log P(x_i \\mid \\theta)<br>$$<\/li>\n\n\n\n<li><strong>Prior \\( P(\\theta) \\)<\/strong>: The prior distribution reflects our beliefs about \\( \\theta \\) before observing the data. Common choices for priors include uniform, Gaussian, or other distributions depending on the problem context.<\/li>\n\n\n\n<li><strong>Posterior Maximization<\/strong>: Combining the log-likelihood and the log-prior, we have: $$ \\hat{\\theta}{\\text{MAP}} = \\arg\\max{\\theta} \\left( \\sum_{i=1}^{n} \\log P(x_i \\mid \\theta) + \\log P(\\theta) \\right)$$ This equation shows that the MAP estimate balances the fit of the model to the data (through the likelihood) with the prior belief about \\( \\theta \\).<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Example<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Suppose we have a Gaussian likelihood and a Gaussian prior. The observed data \\( x_1, x_2, \\ldots, x_n \\) are assumed to be normally distributed with mean \\( \\mu \\) and known variance \\( \\sigma^2 \\):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$$ P(x_i \\mid \\mu) = \\frac{1}{\\sqrt{2 \\pi \\sigma^2}} \\exp \\left( -\\frac{(x_i &#8211; \\mu)^2}{2 \\sigma^2} \\right) $$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the prior distribution for \\( \\mu \\) is also Gaussian with mean \\( \\mu_0 \\) and variance \\( \\tau^2 \\):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$$ P(\\mu) = \\frac{1}{\\sqrt{2 \\pi \\tau^2}} \\exp \\left( -\\frac{(\\mu &#8211; \\mu_0)^2}{2 \\tau^2} \\right) $$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The log-posterior is then:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$$ \\log P(\\mathbf{X} \\mid \\mu) + \\log P(\\mu) = -\\frac{n}{2} \\log(2 \\pi \\sigma^2) &#8211; \\frac{1}{2 \\sigma^2} \\sum_{i=1}^{n} (x_i &#8211; \\mu)^2 &#8211; \\frac{1}{2} \\log(2 \\pi \\tau^2) &#8211; \\frac{1}{2 \\tau^2} (\\mu &#8211; \\mu_0)^2 $$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ignoring constant terms and simplifying, we get:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$$ \\hat{\\mu}{\\text{MAP}} = \\arg\\max{\\mu} \\left( -\\frac{1}{2 \\sigma^2} \\sum_{i=1}^{n} (x_i &#8211; \\mu)^2 &#8211; \\frac{1}{2 \\tau^2} (\\mu &#8211; \\mu_0)^2 \\right) $$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This can be solved by taking the derivative with respect to \\( \\mu \\), setting it to zero, and solving for \\( \\mu \\):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$$ \\frac{\\partial}{\\partial \\mu} \\left( -\\frac{1}{2 \\sigma^2} \\sum_{i=1}^{n} (x_i &#8211; \\mu)^2 &#8211; \\frac{1}{2 \\tau^2} (\\mu &#8211; \\mu_0)^2 \\right) = 0 $$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$$ \\frac{1}{\\sigma^2} \\sum_{i=1}^{n} (x_i &#8211; \\mu) + \\frac{1}{\\tau^2} (\\mu &#8211; \\mu_0) = 0 $$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$$ \\mu \\left( \\frac{n}{\\sigma^2} + \\frac{1}{\\tau^2} \\right) = \\frac{1}{\\sigma^2} \\sum_{i=1}^{n} x_i + \\frac{\\mu_0}{\\tau^2} $$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$$ \\hat{\\mu}{\\text{MAP}} = \\frac{\\frac{1}{\\sigma^2} \\sum{i=1}^{n} x_i + \\frac{\\mu_0}{\\tau^2}}{\\frac{n}{\\sigma^2} + \\frac{1}{\\tau^2}} $$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This result shows that the MAP estimate is a weighted average of the sample mean and the prior mean, with weights inversely proportional to their variances.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Maximum a Posteriori (MAP) estimation is a popular method in Bayesian statistics to estimate an unknown quanti<\/p>\n","protected":false},"author":1,"featured_media":439,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-413","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-differential-equation"],"_links":{"self":[{"href":"https:\/\/mp-superkler.com\/index.php?rest_route=\/wp\/v2\/posts\/413","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mp-superkler.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mp-superkler.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mp-superkler.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mp-superkler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=413"}],"version-history":[{"count":17,"href":"https:\/\/mp-superkler.com\/index.php?rest_route=\/wp\/v2\/posts\/413\/revisions"}],"predecessor-version":[{"id":438,"href":"https:\/\/mp-superkler.com\/index.php?rest_route=\/wp\/v2\/posts\/413\/revisions\/438"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mp-superkler.com\/index.php?rest_route=\/wp\/v2\/media\/439"}],"wp:attachment":[{"href":"https:\/\/mp-superkler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mp-superkler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mp-superkler.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}