{
  "id": "maximum-a-posteriori-estimation",
  "title": "最大后验估计",
  "lang": "zh-Hans",
  "source_lang": "en",
  "summary": "最大后验估计结合观测数据与先验分布，选取使后验概率或密度最大的参数值。",
  "category": "mathematics",
  "subcategory": "probability-statistics",
  "type": "concept",
  "aliases": [
    "最大后验概率估计",
    "MAP估计",
    "后验众数估计"
  ],
  "generated_at": "2026-10-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/zh/maximum-a-posteriori-estimation/",
  "translations": {
    "en": {
      "url": "https://aiwiki.page/en/maximum-a-posteriori-estimation/",
      "json": "https://aiwiki.page/en/maximum-a-posteriori-estimation.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "最大后验估计通常简称为 MAP 估计，是一种贝叶斯推断方法，以使后验分布达到最大值的参数值作为未知参数的估计。它将观测提供的证据与可能参数值上的先验分布相结合。与保留整个后验分布的方法不同，MAP 给出的是点估计。它与最大似然估计密切相关，但在优化目标中纳入了先验。(cs.cmu.edu)"
    },
    {
      "heading": "数学定义",
      "text": "设 \\(D\\) 表示观测数据，\\(\\theta\\) 是属于参数空间 \\(\\Theta\\) 的参数。根据贝叶斯定理，\n\n\\[p(\\theta\\mid D) =\\frac{p(D\\mid\\theta)p(\\theta)}{p(D)}.\\]\n\n这里，将 \\(p(D\\mid\\theta)\\) 视为 \\(\\theta\\) 的函数时，它就是似然函数；而 \\(p(D)\\) 是边际似然。只要后验分布有明确定义，MAP 估计就满足\n\n\\[\\hat{\\theta}_{\\mathrm{MAP}} \\in\\operatorname*{arg\\,max}_{\\theta\\in\\Theta} p(\\theta\\mid D).\\]\n\n使用集合归属符号，是为了允许存在多个同样达到最大值的参数值。由于分母与 \\(\\theta\\) 无关，最大化时可以将其省略。在相关密度均为正的地方，取对数可得到等价的目标函数：\n\n\\[\\hat{\\theta}_{\\mathrm{MAP}} \\in\\operatorname*{arg\\,max}_{\\theta\\in\\Theta} \\left[\\log p(D\\mid\\theta)+\\log p(\\theta)\\right].\\]\n\n(cs.cmu.edu)\n\n对于离散参数，MAP 最大化的是后验概率质量。对于连续参数，它最大化的是概率密度函数，而不是参数恰好取某个值的概率：单个点的概率通常为零。因此，该估计确定的是密度的峰值位置，而不是包含大部分后验概率的区域。(mc-stan.org)"
    },
    {
      "heading": "与最大似然及正则化的关系",
      "text": "最大似然估计仅依据 \\(p(D\\mid\\theta)\\) 选择参数，MAP 则依据乘积 \\(p(D\\mid\\theta)p(\\theta)\\) 选择参数。如果先验在相关参数空间内处处为常数，使目标达到最大值的参数值就不会改变。不过，无界空间上的常数密度通常不是正规的概率分布，因此讨论两者的等价性时，必须仔细考虑先验的支撑集及归一化问题。(cs229.stanford.edu)\n\n将负对数后验最小化，可以清楚地看出 MAP 与正则化的联系：\n\n\\[\\hat{\\theta}_{\\mathrm{MAP}} \\in\\operatorname*{arg\\,min}_{\\theta} \\left[-\\log p(D\\mid\\theta)-\\log p(\\theta)\\right].\\]\n\n第一项衡量模型与观测的不一致程度；第二项则充当参数惩罚项。各分量相互独立、均值为零的正态分布先验会产生平方 \\(L_2\\) 惩罚项。相互独立、以零为中心的拉普拉斯分布先验会产生 \\(L_1\\) 惩罚项。因此，在特定概率假设下，机器学习中常见的正则化目标可以解释为 MAP 估计。(cs229.stanford.edu)\n\n例如，在线性回归中，若噪声相互独立且服从正态分布，已知其方差为 \\(\\sigma^2\\)，并为回归系数设置协方差为 \\(\\tau^2I\\) 的正态先验，则有\n\n\\[\\hat{\\beta}_{\\mathrm{MAP}} =\\operatorname*{arg\\,min}_{\\beta} \\left[ \\frac{\\|y-X\\beta\\|_2^2}{2\\sigma^2} +\\frac{\\|\\beta\\|_2^2}{2\\tau^2} \\right].\\]\n\n这就是岭回归，其惩罚强度由噪声方差与先验方差的比值决定。如果数据拟合项采用平均值而不是总和，惩罚系数的数值还会取决于样本量。若改为对系数设置拉普拉斯先验，则会得到套索回归。(www2.stat.duke.edu)"
    },
    {
      "heading": "示例：估计伯努利成功概率",
      "text": "假设 \\(n\\) 个相互独立的观测服从成功概率为 \\(\\theta\\) 的伯努利分布，其中观察到 \\(k\\) 次成功。为 \\(\\theta\\) 指定一个贝塔分布先验：\n\n\\[\\theta\\sim\\operatorname{Beta}(\\alpha,\\beta).\\]\n\n这是一个共轭先验：后验仍属于同一分布族，\n\n\\[\\theta\\mid D\\sim \\operatorname{Beta}(\\alpha+k,\\beta+n-k).\\]\n\n当后验的两个形状参数都大于 1 时，其唯一的内部众数为\n\n\\[\\hat{\\theta}_{\\mathrm{MAP}} =\\frac{k+\\alpha-1}{n+\\alpha+\\beta-2}.\\]\n\n这一公式可通过对数后验求导得到；若不满足上述条件，则需要考虑边界处的行为或众数不唯一的情况。(cs.cmu.edu)\n\n若先验为 \\(\\operatorname{Beta}(2,2)\\)，且十次试验中有八次成功，则该公式给出 \\(9/12=0.75\\)，而最大似然估计为 \\(0.8\\)。后验均值则为\n\n\\[\\mathbb{E}[\\theta\\mid D] =\\frac{k+\\alpha}{n+\\alpha+\\beta},\\]\n\n得到 \\(10/14\\)，约为 \\(0.714\\)。这些数值说明，后验分布的众数与期望值不一定相同。(cs.cmu.edu)"
    },
    {
      "heading": "计算与解释",
      "text": "MAP 估计是一个数学优化问题。简单的共轭模型可能有解析解；较复杂的模型则需要数值方法。对于光滑的目标函数，可以使用牛顿法，或 BFGS、L-BFGS 等拟牛顿算法进行优化。数值算法终止本身并不能证明已经找到全局最大值，尤其是在后验分布具有多个峰的情况下。(mc-stan.org)\n\n在决策理论中，何种点估计最优取决于损失函数。对于离散参数，在零—一损失下，选择后验众数可以使后验期望损失最小。在平方误差损失下，使损失最小的估计是后验均值，通常并非 MAP。对于连续参数，严格的零—一损失无法区分各个候选值；要通过不断缩小的邻域来解释 MAP，还需要额外的正则性条件。(hsong1.github.io)"
    },
    {
      "heading": "局限性",
      "text": "连续参数的 MAP 估计依赖于参数化方式。对于可逆且可微的变换 \\(\\phi=g(\\theta)\\)，变换后的后验密度包含一个涉及雅可比矩阵的因子：\n\n\\[p_{\\phi}(\\phi\\mid D) =p_{\\theta}(g^{-1}(\\phi)\\mid D) \\left|\\det Dg^{-1}(\\phi)\\right|.\\]\n\n因此，即使底层的后验概率测度没有改变，对 MAP 估计进行变换，也不一定能得到新坐标下的 MAP 估计。(mc-stan.org)\n\n单个众数还会遗漏后验分布的离散程度、不对称性、依赖关系以及其他众数。将 MAP 参数代入预测模型，通常不同于计算后验预测分布；后者会对参数的不确定性进行积分，得到平均预测。因此，MAP 提供的是一种特定的点概括，而不是对贝叶斯不确定性的完整描述。(cs229.stanford.edu)"
    }
  ],
  "links": [
    "bayesian-inference",
    "posterior-distribution",
    "prior-distribution",
    "maximum-likelihood-estimation",
    "bayes-theorem",
    "likelihood-function",
    "marginal-likelihood",
    "objective-function",
    "probability-density-function",
    "regularization",
    "normal-distribution",
    "laplace-distribution",
    "machine-learning",
    "linear-regression",
    "variance",
    "ridge-regression",
    "lasso-regression",
    "bernoulli-distribution",
    "beta-distribution",
    "conjugate-prior",
    "expected-value",
    "mathematical-optimization",
    "newtons-method",
    "decision-theory",
    "loss-function",
    "jacobian-matrix",
    "posterior-predictive-distribution"
  ],
  "sources": [
    {
      "title": "cs.cmu.edu/~epxing/Class/DS/lectures/lecture1.pdf",
      "url": "https://www.cs.cmu.edu/~epxing/Class/DS/lectures/lecture1.pdf"
    },
    {
      "title": "mc-stan.org/docs/stan-users-guide/reparameterization.html",
      "url": "https://mc-stan.org/docs/stan-users-guide/reparameterization.html"
    },
    {
      "title": "cs229.stanford.edu/summer2022/cs229-notes5.pdf",
      "url": "https://cs229.stanford.edu/summer2022/cs229-notes5.pdf"
    },
    {
      "title": "cs229.stanford.edu/summer2019/ps2.pdf",
      "url": "https://cs229.stanford.edu/summer2019/ps2.pdf"
    },
    {
      "title": "www2.stat.duke.edu/~sayan/561/2015/stat_ml.pdf",
      "url": "https://www2.stat.duke.edu/~sayan/561/2015/stat_ml.pdf"
    },
    {
      "title": "mc-stan.org/docs/reference-manual/optimization.html",
      "url": "https://mc-stan.org/docs/reference-manual/optimization.html"
    },
    {
      "title": "hsong1.github.io/teachings/psu-sp21-stat415/7_Bayesian%20Estimation.html",
      "url": "https://hsong1.github.io/teachings/psu-sp21-stat415/7_Bayesian%20Estimation.html"
    }
  ],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}