{
  "id": "posterior-predictive-distribution",
  "title": "后验预测分布",
  "lang": "zh-Hans",
  "source_lang": "en",
  "summary": "后验预测分布对模型参数的后验不确定性进行平均，以描述未观测结果的分布。",
  "category": "mathematics",
  "subcategory": "probability-statistics",
  "type": "concept",
  "aliases": [
    "贝叶斯后验预测分布"
  ],
  "generated_at": "2026-10-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/zh/posterior-predictive-distribution/",
  "translations": {
    "en": {
      "url": "https://aiwiki.page/en/posterior-predictive-distribution/",
      "json": "https://aiwiki.page/en/posterior-predictive-distribution.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "后验预测分布是贝叶斯推断中，给定已观测数据时未观测结果的概率分布。它同时考虑了模型参数的不确定性，以及在任一给定参数值下结果本身的变异性。后验分布描述的是未知参数，而后验预测分布描述的是可观测量，例如未来的测量值、缺失的观测值，或假设重复进行实验时得到的结果。因此，它给出的是各种可能结果的分布，而不只是一个点预测。(mc-stan.org)"
    },
    {
      "heading": "数学定义",
      "text": "设 \\(y\\) 表示已观测数据，\\(\\theta\\) 表示模型参数，\\(\\tilde y\\) 表示一个未观测结果。贝叶斯模型指定先验分布 \\(p(\\theta)\\) 和似然函数 \\(p(y\\mid\\theta)\\)，再通过贝叶斯定理确定 \\(p(\\theta\\mid y)\\)。预测分布为\n\n\\[p(\\tilde y\\mid y) =\\int p(\\tilde y\\mid\\theta,y)\\, p(\\theta\\mid y)\\,d\\theta.\\]\n\n如果给定 \\(\\theta\\) 时，\\(\\tilde y\\) 与 \\(y\\) 条件独立，则上式变为\n\n\\[p(\\tilde y\\mid y) =\\int p(\\tilde y\\mid\\theta)\\, p(\\theta\\mid y)\\,d\\theta.\\]\n\n通过积分，可以从参数与预测结果的联合概率分布中消去参数。对于离散参数，则需用求和代替积分。符号 \\(p\\) 可以表示概率密度函数或概率质量函数，具体取决于结果的类型。所得分布是以参数后验分布为权重的各条件结果分布的混合。(statproofbook.github.io)\n\n对于回归问题，若已观测的预测变量为 \\(x\\)，新的预测变量为 \\(\\tilde x\\)，则相应表达式为\n\n\\[p(\\tilde y\\mid\\tilde x,x,y) =\\int p(\\tilde y\\mid\\tilde x,\\theta) p(\\theta\\mid x,y)\\,d\\theta.\\]\n\n因此，预测既取决于拟合得到的模型，也取决于新结果产生时的条件。(mc-stan.org)"
    },
    {
      "heading": "预测不确定性的来源",
      "text": "预测不确定性既包括参数的不确定性，也包括给定参数时结果的变异性。当相关矩存在时，预测期望值满足\n\n\\[\\mathbb E[\\tilde Y\\mid y] =\\mathbb E_{\\theta\\mid y} \\!\\left[\\mathbb E(\\tilde Y\\mid\\theta,y)\\right],\\]\n\n其方差可分解为\n\n\\[\\operatorname{Var}(\\tilde Y\\mid y) = \\mathbb E_{\\theta\\mid y} [\\operatorname{Var}(\\tilde Y\\mid\\theta,y)] + \\operatorname{Var}_{\\theta\\mid y} [\\mathbb E(\\tilde Y\\mid\\theta,y)].\\]\n\n第一项是观测模型内部变异性的平均值；第二项衡量不同合理参数值所对应的条件均值之间的变异。这两式分别是条件期望和全方差公式的应用。(sites.stat.columbia.edu)\n\n将最大似然估计值或其他点估计值代入得到的预测 \\(p(\\tilde y\\mid\\hat\\theta)\\)，并未进行上述平均。尤其需要注意，条件均值的不确定性并不等同于实际未来观测值的不确定性。即使参数已被精确确定，结果仍可能具有很大的变异性。(mc-stan.org)"
    },
    {
      "heading": "共轭模型示例",
      "text": "假设在 \\(n\\) 次试验中观测到 \\(s\\) 次成功，且各次试验具有相同的成功概率 \\(\\theta\\)。贝塔分布是二项分布模型的共轭先验：\n\n\\[\\theta\\sim\\operatorname{Beta}(\\alpha,\\beta), \\qquad \\theta\\mid y\\sim \\operatorname{Beta}(\\alpha+s,\\beta+n-s).\\]\n\n对于再进行的一次试验，预测结果服从伯努利分布，其成功概率为\n\n\\[\\Pr(\\tilde Y=1\\mid y) =\\frac{\\alpha+s}{\\alpha+\\beta+n}.\\]\n\n对于再进行的 \\(m\\) 次试验，将其二项分布对上述后验分布积分，便得到贝塔—二项分布。整批未来试验共用一次抽取的参数值；如果为每次试验分别独立抽取一个参数值，就会定义出不同的联合预测模型。(statproofbook.github.io)\n\n作为连续型示例，假设观测值服从正态分布，其均值 \\(\\mu\\) 未知，方差 \\(\\sigma^2\\) 已知。如果\n\n\\[\\mu\\mid y\\sim N(m_n,v_n),\\]\n\n则新观测值的分布为\n\n\\[\\tilde Y\\mid y\\sim N(m_n,\\sigma^2+v_n).\\]\n\n其方差明确包含了观测值的变异性和均值的后验不确定性。因此，\\(\\mu\\) 的可信区间不同于 \\(\\tilde Y\\) 的预测区间。(tensorflow.org)"
    },
    {
      "heading": "计算与汇总",
      "text": "当无法进行解析积分时，蒙特卡洛方法可以提供实用的近似。先抽取参数值，通常通过马尔可夫链蒙特卡洛获得，再模拟结果：\n\n\\[\\theta^{(r)}\\sim p(\\theta\\mid y), \\qquad \\tilde y^{(r)}\\sim p(\\tilde y\\mid\\theta^{(r)},y).\\]\n\n第二步必不可少：如果只保留条件均值，就会遗漏结果本身的变异性。预测样本可用于估计分位数、事件概率以及其他汇总统计量。(mc-stan.org)\n\n另一种方法是对条件密度取平均，以估计某个指定结果处的预测密度：\n\n\\[p(\\tilde y\\mid y) \\approx\\frac1R\\sum_{r=1}^{R} p(\\tilde y\\mid\\theta^{(r)},y).\\]\n\n密度计算与结果模拟相互关联，但属于不同的操作。当密度非常小时，采用数值稳定的 log-sum-exp（指数和的对数）计算有助于避免数值下溢。(mc-stan.org)"
    },
    {
      "heading": "模型检验与预测评估",
      "text": "在后验预测检验中，将拟合模型生成的重复数据集与已观测数据进行比较。比较可以考察离散程度、极端值、零值比例或其他特征。这类检验用于评估模型能否再现观测数据的某些特征，其本身并不是对模型在真正未见过的数据上的表现进行检验。(mc-stan.org)\n\n样本外评估则使用预留的观测数据，例如采用交叉验证。此时，相应的预测分布以训练子集而非完整数据集为条件。预测均值使期望平方误差最小，而其他损失函数可能更适合采用不同的汇总量。预测区间描述的是给定模型和数据条件下的不确定性；它在实际应用中是否恰当，仍取决于观测模型和预测情境。(mc-stan.org)"
    }
  ],
  "links": [
    "bayesian-inference",
    "probability-distribution",
    "posterior-distribution",
    "prior-distribution",
    "likelihood-function",
    "bayes-theorem",
    "conditional-independence",
    "integral",
    "joint-probability-distribution",
    "probability-density-function",
    "probability-mass-function",
    "expected-value",
    "variance",
    "maximum-likelihood-estimation",
    "beta-distribution",
    "binomial-distribution",
    "conjugate-prior",
    "bernoulli-distribution",
    "normal-distribution",
    "credible-interval",
    "prediction-interval",
    "monte-carlo-method",
    "markov-chain-monte-carlo",
    "posterior-predictive-checking",
    "cross-validation"
  ],
  "sources": [
    {
      "title": "Stan User’s Guide",
      "url": "https://mc-stan.org/docs/2_31/stan-users-guide-2_31.pdf"
    },
    {
      "title": "2 Computing the posterior predictive distribution",
      "url": "https://mc-stan.org/docs/2_29/stan-users-guide/computing-the-posterior-predictive-distribution.html"
    },
    {
      "title": "3 Sampling from the posterior predictive distribution",
      "url": "https://mc-stan.org/docs/2_31/stan-users-guide/sampling-from-the-posterior-predictive-distribution.html"
    },
    {
      "title": "Posterior Predictive Sampling",
      "url": "https://mc-stan.org/docs/2_38/stan-users-guide/posterior-prediction.html"
    },
    {
      "title": "Posterior predictive distribution — The Book of Statistical Proofs",
      "url": "https://statproofbook.github.io/D/post-pred.html"
    },
    {
      "title": "Posterior distribution for binomial observations",
      "url": "https://statproofbook.github.io/P/bin-post.html"
    },
    {
      "title": "Bayesian Data Analysis, third edition",
      "url": "https://sites.stat.columbia.edu/gelman/book/BDA3.pdf"
    },
    {
      "title": "A conservation law for posterior predictive variance",
      "url": "https://arxiv.org/abs/2406.11806"
    },
    {
      "title": "STAT415 Handouts — Beta-Binomial Model",
      "url": "https://bookdown.org/kevin_davisross/stat415-handouts/beta-binomial.html"
    },
    {
      "title": "Posterior Predictive Distribution for Beta-Binomial model",
      "url": "https://www.cs.ubc.ca/~murphyk/pmtk/pmtk1/doc/examples/binom_betaPostPredDemo.html"
    },
    {
      "title": "tfp.distributions.normal_conjugates_known_scale_predictive",
      "url": "https://www.tensorflow.org/probability/api_docs/python/tfp/distributions/normal_conjugates_known_scale_predictive"
    }
  ],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}