Skip to content

Wikipedia Bayesian Statistics Concepts (维基百科贝叶斯统计概念)

来源: Wikipedia (英文维基百科)
编译时间: 2026-06-01
状态: 中英对照编译
基于: Bayesian statistics, Bayesian inference, MCMC 等条目
关联: 统计学概念, 因果推断第 10 章


📚 目录 (Table of Contents)

  1. 贝叶斯统计基础
  2. 贝叶斯推断
  3. 先验分布
  4. 马尔可夫链蒙特卡洛
  5. 贝叶斯模型比较
  6. 变分贝叶斯方法

1. 贝叶斯统计基础 (Bayesian Statistics Basics)

1.1 贝叶斯定理 (Bayes' Theorem)

英文:

Bayes' theorem describes the probability of an event, based on prior knowledge of conditions that might be related to the event.

中文:

贝叶斯定理描述事件的概率,基于可能与该事件相关的条件的先验知识。

贝叶斯公式 (Bayes' Formula):

\[ P(A|B) = \frac{P(B|A) P(A)}{P(B)} \]

其中: - \(P(A|B)\): 后验概率 (posterior probability) - 给定 B 后 A 的概率 - \(P(B|A)\): 似然 (likelihood) - 给定 A 后 B 的概率 - \(P(A)\): 先验概率 (prior probability) - A 的初始概率 - \(P(B)\): 边缘似然 (marginal likelihood) - B 的总概率

统计推断形式 (Statistical Inference Form):

\[ P(\theta|D) = \frac{P(D|\theta) P(\theta)}{P(D)} \]

其中: - \(\theta\): 模型参数 - \(D\): 观测数据 - \(P(\theta|D)\): 参数的后验分布 - \(P(D|\theta)\): 似然函数 - \(P(\theta)\): 参数的先验分布 - \(P(D)\): 模型证据 (边缘似然)

1.2 贝叶斯 vs 频率学派 (Bayesian vs Frequentist)

方面 频率学派 (Frequentist) 贝叶斯学派 (Bayesian)
参数解释 固定但未知的常数 随机变量,有概率分布
概率解释 长期频率 信念程度
推断结果 点估计 + 置信区间 后验分布 + 可信区间
先验信息 不使用 显式使用先验分布
计算复杂度 通常较简单 通常较复杂 (需要 MCMC)
小样本表现 可能不稳定 先验提供正则化

1.3 贝叶斯推断流程 (Bayesian Inference Workflow)

1. 指定先验分布 P(θ)
2. 收集数据 D
3. 计算似然 P(D|θ)
4. 应用贝叶斯定理
   P(θ|D) = P(D|θ)P(θ) / P(D)
5. 计算后验分布 P(θ|D)
6. 基于后验进行推断
   (点估计、区间估计、预测)

2. 贝叶斯推断 (Bayesian Inference)

2.1 共轭先验 (Conjugate Priors)

英文:

A conjugate prior is a prior distribution that, when combined with the likelihood function, produces a posterior distribution of the same family.

中文:

共轭先验是与似然函数结合后产生同族后验分布的先验分布。

常见共轭先验 (Common Conjugate Priors):

似然分布 参数 共轭先验 后验分布
伯努利/二项 p Beta(α, β) Beta(α+k, β+n-k)
泊松 λ Gamma(α, β) Gamma(α+Σxᵢ, β+n)
正态 (已知方差) μ 正态 (μ₀, σ₀²) 正态 (μₙ, σₙ²)
正态 (已知均值) σ² Inverse-Gamma(α, β) Inverse-Gamma(α+n/2, β+Σ(xᵢ-μ)²/2)
多项 p Dirichlet(α) Dirichlet(α+n)

2.2 Beta-Binomial 模型 (Beta-Binomial Model)

英文:

The Beta-Binomial model is a canonical example of Bayesian inference with conjugate priors.

中文:

Beta-Binomial 模型是共轭先验贝叶斯推断的经典示例。

模型设定 (Model Specification):

  • 似然:\(X \sim \text{Binomial}(n, p)\)
  • 先验:\(p \sim \text{Beta}(\alpha, \beta)\)
  • 后验:\(p|X \sim \text{Beta}(\alpha + X, \beta + n - X)\)

后验均值 (Posterior Mean):

\[ \mathbb{E}[p|X] = \frac{\alpha + X}{\alpha + \beta + n} \]

Python 实现 (Python Implementation):

import numpy as np
from scipy import stats
import matplotlib.pyplot as plt

def beta_binomial_update(alpha_prior, beta_prior, successes, trials):
    """
    Beta-Binomial 共轭更新

    参数:
        alpha_prior, beta_prior: Beta 先验参数
        successes: 成功次数 k
        trials: 总试验次数 n

    返回:
        alpha_post, beta_post: Beta 后验参数
    """
    alpha_post = alpha_prior + successes
    beta_post = beta_prior + (trials - successes)

    return alpha_post, beta_post

# 可视化先验和后验
def plot_beta_update(alpha_prior, beta_prior, k, n):
    alpha_post, beta_post = beta_binomial_update(alpha_prior, beta_prior, k, n)

    p = np.linspace(0, 1, 500)

    # 先验
    prior = stats.beta.pdf(p, alpha_prior, beta_prior)
    # 后验
    posterior = stats.beta.pdf(p, alpha_post, beta_post)

    plt.figure(figsize=(10, 6))
    plt.plot(p, prior, label=f'Prior: Beta({alpha_prior}, {beta_prior})', 
             linestyle='--', alpha=0.7)
    plt.plot(p, posterior, label=f'Posterior: Beta({alpha_post}, {beta_post})', 
             linewidth=2)
    plt.xlabel('p (probability of success)')
    plt.ylabel('Density')
    plt.title(f'Beta-Binomial Update: {k} successes in {n} trials')
    plt.legend()
    plt.grid(True, alpha=0.3)
    plt.show()

# 使用示例
# plot_beta_update(alpha_prior=2, beta_prior=2, k=7, n=10)

2.3 正态 - 正态模型 (Normal-Normal Model)

英文:

When the likelihood is normal with known variance and the prior on the mean is normal, the posterior is also normal.

中文:

当似然是方差已知的正态分布且均值的先验是正态分布时,后验也是正态分布。

模型设定 (Model Specification):

  • 数据:\(X_1, \ldots, X_n \sim \mathcal{N}(\mu, \sigma^2)\) (σ² 已知)
  • 先验:\(\mu \sim \mathcal{N}(\mu_0, \tau_0^2)\)
  • 后验:\(\mu|X \sim \mathcal{N}(\mu_n, \tau_n^2)\)

后验参数 (Posterior Parameters):

\[ \tau_n^2 = \left( \frac{1}{\tau_0^2} + \frac{n}{\sigma^2} \right)^{-1} \]
\[ \mu_n = \tau_n^2 \left( \frac{\mu_0}{\tau_0^2} + \frac{n\bar{x}}{\sigma^2} \right) \]

后验均值的解释 (Interpretation of Posterior Mean):

\[ \mu_n = w \mu_0 + (1-w) \bar{x} \]

其中权重 \(w = \frac{\sigma^2/n}{\sigma^2/n + \tau_0^2}\)


3. 先验分布 (Prior Distributions)

3.1 先验选择原则 (Principles of Prior Selection)

英文:

Prior selection should reflect genuine prior knowledge or use non-informative priors when little is known.

中文:

先验选择应反映真实的先验知识,或在知之甚少时使用无信息先验。

先验类型 英文 中文 适用场景
Informative 信息先验 有明确先验知识 历史数据可用
Weakly informative 弱信息先验 轻微正则化 防止极端值
Non-informative 无信息先验 最小化先验影响 客观推断
Reference 参考先验 形式化无信息 理论分析
Conjugate 共轭先验 解析后验 计算便利

3.2 Jeffreys 先验 (Jeffreys Prior)

英文:

Jeffreys prior is a non-informative prior that is invariant under reparameterization, proportional to the square root of the Fisher information.

中文:

Jeffreys 先验是一种无信息先验,在重参数化下不变,与 Fisher 信息的平方根成正比。

Jeffreys 先验公式 (Jeffreys Prior Formula):

\[ p_J(\theta) \propto \sqrt{\det I(\theta)} \]

其中 \(I(\theta)\) 是 Fisher 信息矩阵:

\[ I(\theta) = \mathbb{E}\left[ \left(\frac{\partial}{\partial \theta} \log L(\theta; X)\right)^2 \middle| \theta \right] \]

常见 Jeffreys 先验 (Common Jeffreys Priors):

分布 参数 Jeffreys 先验
伯努利 p Beta(½, ½)
泊松 λ \(\lambda^{-1/2}\)
正态 (μ, σ² 都未知) μ 常数 (均匀)
正态 (μ, σ² 都未知) σ² \(1/\sigma^2\)
指数 λ \(1/\lambda\)

3.3 分层先验 (Hierarchical Priors)

英文:

Hierarchical priors introduce hyperpriors on the parameters of the prior distribution, allowing for partial pooling of information.

中文:

分层先验在先验分布的参数上引入超先验,允许信息的部分池化。

分层模型结构 (Hierarchical Model Structure):

超先验 (Hyperprior)
    P(φ)
超参数 (Hyperparameter)
    φ
先验 (Prior)
    P(θ|φ)
参数 (Parameter)
    θ
似然 (Likelihood)
    P(D|θ)

八学校例 (Eight Schools Example):

\[ \begin{aligned} y_j &\sim \mathcal{N}(\theta_j, \sigma_j^2) & \text{(学校效应)} \\ \theta_j &\sim \mathcal{N}(\mu, \tau^2) & \text{(群体分布)} \\ \mu &\sim \mathcal{N}(0, 100) & \text{(超先验)} \\ \tau &\sim \text{Half-Cauchy}(0, 25) & \text{(超先验)} \end{aligned} \]

4. 马尔可夫链蒙特卡洛 (Markov Chain Monte Carlo)

4.1 MCMC 基础 (MCMC Basics)

英文:

MCMC methods are a class of algorithms for sampling from a probability distribution based on constructing a Markov chain that has the desired distribution as its equilibrium distribution.

中文:

MCMC 方法是一类基于构建马尔可夫链从概率分布中采样的算法,该马尔可夫链以期望分布为其平衡分布。

MCMC 基本思想 (MCMC Basic Idea):

目标: 从复杂分布 P(θ|D) 采样

方法:
1. 构建马尔可夫链
   - 状态空间: 参数空间
   - 转移核: 设计为以 P(θ|D) 为平稳分布

2. 运行链
   - 从任意初始点开始
   - 迭代采样

3. 收敛后
   - 样本近似服从目标分布
   - 用样本估计后验统计量

4.2 Metropolis-Hastings 算法 (Metropolis-Hastings Algorithm)

英文:

The Metropolis-Hastings algorithm is a MCMC method for obtaining a sequence of random samples from a probability distribution for which direct sampling is difficult.

中文:

Metropolis-Hastings 算法是一种 MCMC 方法,用于从直接采样困难的概率分布中获得随机样本序列。

MH 算法 (MH Algorithm):

初始化 θ⁽⁰⁾

For t = 0, 1, 2, ...:
  1. 从提议分布生成候选值: θ* ~ q(θ*|θ⁽ᵗ⁾)
  2. 计算接受概率:
     α = min(1, [P(θ*|D) q(θ⁽ᵗ⁾|θ*)] / [P(θ⁽ᵗ⁾|D) q(θ*|θ⁽ᵗ⁾)])
  3. 以概率 α 接受 θ*:
     - 如果接受: θ⁽ᵗ⁺¹⁾ = θ*
     - 否则: θ⁽ᵗ⁺¹⁾ = θ⁽ᵗ⁾

返回样本 {θ⁽ᵗ⁾}

Python 实现 (Python Implementation):

import numpy as np

def metropolis_hastings(log_posterior, proposal_std, x0, n_samples, burn_in=1000):
    """
    Metropolis-Hastings 算法

    参数:
        log_posterior: 对数后验函数
        proposal_std: 提议分布标准差
        x0: 初始值
        n_samples: 样本数量
        burn_in: 退火期长度

    返回:
        samples: MCMC 样本
    """
    samples = np.zeros(n_samples)
    x_current = x0
    log_p_current = log_posterior(x_current)

    accepted = 0

    for i in range(n_samples + burn_in):
        # 提议新值
        x_proposed = np.random.normal(x_current, proposal_std)
        log_p_proposed = log_posterior(x_proposed)

        # 计算接受概率
        log_alpha = log_p_proposed - log_p_current
        alpha = np.exp(log_alpha)

        # 接受/拒绝
        if np.random.random() < alpha:
            x_current = x_proposed
            log_p_current = log_p_proposed
            if i >= burn_in:
                accepted += 1

        if i >= burn_in:
            samples[i - burn_in] = x_current

    acceptance_rate = accepted / n_samples
    return samples, acceptance_rate

# 使用示例 (Beta-Binomial 后验采样)
# alpha, beta, k, n = 2, 2, 7, 10
# log_posterior = lambda p: stats.beta.logpdf(p, alpha+k, beta+n-k)
# samples, acc_rate = metropolis_hastings(log_posterior, 0.1, 0.5, 10000)

4.3 Gibbs 采样 (Gibbs Sampling)

英文:

Gibbs sampling is a MCMC algorithm that generates samples from a multivariate distribution by iteratively sampling from each variable's conditional distribution.

中文:

Gibbs 采样是一种 MCMC 算法,通过迭代地从每个变量的条件分布中采样来生成多变量分布的样本。

Gibbs 采样算法 (Gibbs Sampling Algorithm):

初始化 θ⁽⁰⁾ = (θ₁⁽⁰⁾, θ₂⁽⁰⁾, ..., θₖ⁽⁰⁾)

For t = 0, 1, 2, ...:
  θ₁⁽ᵗ⁺¹⁾ ~ P(θ₁ | θ₂⁽ᵗ⁾, θ₃⁽ᵗ⁾, ..., θₖ⁽ᵗ⁾, D)
  θ₂⁽ᵗ⁺¹⁾ ~ P(θ₂ | θ₁⁽ᵗ⁺¹⁾, θ₃⁽ᵗ⁾, ..., θₖ⁽ᵗ⁾, D)
  θ₃⁽ᵗ⁺¹⁾ ~ P(θ₃ | θ₁⁽ᵗ⁺¹⁾, θ₂⁽ᵗ⁺¹⁾, ..., θₖ⁽ᵗ⁾, D)
  ...
  θₖ⁽ᵗ⁺¹⁾ ~ P(θₖ | θ₁⁽ᵗ⁺¹⁾, θ₂⁽ᵗ⁺¹⁾, ..., θₖ₋₁⁽ᵗ⁺¹⁾, D)

返回样本序列

4.4 Hamiltonian Monte Carlo (HMC)

英文:

Hamiltonian Monte Carlo is a MCMC method that uses Hamiltonian dynamics to propose new states, allowing for more efficient exploration of the parameter space.

中文:

Hamiltonian Monte Carlo 是一种使用 Hamiltonian 动力学提议新状态的 MCMC 方法,允许更有效地探索参数空间。

HMC 关键概念 (HMC Key Concepts):

概念 英文 中文 说明
Position 位置 目标参数 θ
Momentum 动量 辅助变量 r
Potential energy 势能 U(θ) = -log P(θ|D)
Kinetic energy 动能 K® = rᵀr/2
Hamiltonian 哈密顿量 H(θ,r) = U(θ) + K®

HMC 算法 (HMC Algorithm):

For t = 0, 1, 2, ...:
  1. 采样新动量: r ~ N(0, M)
  2. 模拟 Hamiltonian 动力学 L 步:
     For l = 1 to L:
       r ← r - (ε/2) ∇U(θ)
       θ ← θ + ε M⁻¹ r
       r ← r - (ε/2) ∇U(θ)
  3. 以概率 min(1, exp(H(θ⁽ᵗ⁾,r⁽ᵗ⁾) - H(θ*,r*))) 接受

4.5 MCMC 诊断 (MCMC Diagnostics)

英文:

MCMC diagnostics assess the convergence and mixing of the Markov chain to ensure reliable posterior estimates.

中文:

MCMC 诊断评估马尔可夫链的收敛性和混合性,以确保可靠的后验估计。

诊断工具 (Diagnostic Tools):

诊断 英文 中文 目的
Trace plot 轨迹图 可视化链的历史 检查收敛
Autocorrelation 自相关 样本相关性 检查混合
R-hat (Gelman-Rubin) R-hat 多链比较 收敛诊断
ESS 有效样本量 独立样本估计 精度评估

轨迹图示例 (Trace Plot Example):

收敛良好:                    未收敛:
    │                            │
    │  ════════════              │  ╱╲
    │  ════════════              │ ╱  ╲
    │  ════════════              │╱    ╲
    └──────────────→             └──────────────→
    迭代                          迭代

5. 贝叶斯模型比较 (Bayesian Model Comparison)

5.1 贝叶斯因子 (Bayes Factors)

英文:

The Bayes factor is a ratio of the marginal likelihoods of two competing models, quantifying the evidence in favor of one model over the other.

中文:

贝叶斯因子是两个竞争模型的边缘似然之比,量化支持一个模型而非另一个模型的证据。

贝叶斯因子公式 (Bayes Factor Formula):

\[ BF_{12} = \frac{P(D|M_1)}{P(D|M_2)} = \frac{\int P(D|\theta_1, M_1) P(\theta_1|M_1) d\theta_1}{\int P(D|\theta_2, M_2) P(\theta_2|M_2) d\theta_2} \]

贝叶斯因子解释 (Bayes Factor Interpretation):

BF₁₂ 证据强度 英文
1-3 微弱 Barely worth mentioning
3-10 中等 Substantial
10-30 Strong
30-100 很强 Very strong
>100 决定性的 Decisive

5.2 模型证据 (Model Evidence)

英文:

The model evidence (marginal likelihood) is the probability of the data given the model, integrating over all possible parameter values.

中文:

模型证据 (边缘似然) 是给定模型下数据的概率,对所有可能参数值积分。

模型证据公式 (Model Evidence Formula):

\[ P(D|M) = \int P(D|\theta, M) P(\theta|M) d\theta \]

计算方法 (Computation Methods):

方法 英文 中文 适用场景
解析解 Analytical 共轭模型 简单模型
Laplace 近似 Laplace Approximation 围绕 MLE 近似 单峰后验
BIC BIC 贝叶斯信息准则 大样本
调和均值 Harmonic Mean MCMC 样本 简单但有方差问题
桥采样 Bridge Sampling 改进估计 精确但复杂
嵌套采样 Nested Sampling 证据计算 高维问题

5.3 WAIC 和 LOO-CV

英文:

WAIC (Watanabe-Akaike Information Criterion) and LOO-CV (Leave-One-Out Cross-Validation) are methods for estimating out-of-sample prediction accuracy.

中文:

WAIC (Watanabe-Akaike 信息准则) 和 LOO-CV (留一交叉验证) 是估计样本外预测准确性的方法。

WAIC 公式 (WAIC Formula):

\[ \text{WAIC} = -2 \sum_{i=1}^{n} \log \left( \frac{1}{S} \sum_{s=1}^{S} P(y_i|\theta^{(s)}) \right) + 2 \sum_{i=1}^{n} \text{Var}_{s}(\log P(y_i|\theta^{(s)})) \]

LOO-CV 近似 (LOO-CV Approximation):

使用 Pareto-smoothed importance sampling (PSIS):

\[ \widehat{\text{elpd}}_{\text{loo}} = \sum_{i=1}^{n} \log \left( \frac{1}{S} \sum_{s=1}^{S} w_i^{(s)} P(y_i|\theta^{(s)}) \right) \]

6. 变分贝叶斯方法 (Variational Bayesian Methods)

6.1 变分推断基础 (Variational Inference Basics)

英文:

Variational inference is a method for approximating complex probability distributions by optimizing a simpler distribution to be close to the target distribution.

中文:

变分推断是一种通过优化更简单的分布来逼近复杂概率分布的方法,使其接近目标分布。

变分推断思想 (Variational Inference Idea):

目标: 近似后验 P(θ|D)

方法:
1. 选择变分族 Q = {q(θ|φ)}
2. 优化变分参数 φ 以最小化 KL 散度:
   φ* = argmin_φ KL(q(θ|φ) || P(θ|D))
3. 使用 q(θ|φ*) 作为后验近似

ELBO (Evidence Lower Bound):

\[ \log P(D) = \text{ELBO}(q) + \text{KL}(q(\theta) || P(\theta|D)) \]

其中:

\[ \text{ELBO}(q) = \mathbb{E}_{q}[\log P(D|\theta)] - \text{KL}(q(\theta) || P(\theta)) \]

最大化 ELBO 等价于最小化 KL 散度。

6.2 平均场变分推断 (Mean-Field Variational Inference)

英文:

Mean-field variational inference assumes that the variational distribution factorizes over disjoint subsets of variables.

中文:

平均场变分推断假设变分分布在变量的不相交子集上分解。

平均场假设 (Mean-Field Assumption):

\[ q(\theta) = \prod_{j=1}^{m} q_j(\theta_j) \]

坐标上升更新 (Coordinate Ascent Update):

\[ \log q_j^*(\theta_j) = \mathbb{E}_{q_{-j}}[\log P(\theta, D)] + \text{const} \]

6.3 变分自编码器 (Variational Autoencoder)

英文:

VAE is a generative model that combines variational inference with deep neural networks to learn latent representations.

中文:

VAE 是一种生成模型,结合变分推断与深度神经网络来学习潜在表示。

VAE 架构 (VAE Architecture):

输入 x
┌──────────────┐
│  编码器 q_φ  │
│  Encoder     │
└──────┬───────┘
   μ, σ² (潜变量参数)
   重参数化技巧: z = μ + σ ⊙ ε
┌──────────────┐
│  解码器 p_θ  │
│  Decoder     │
└──────┬───────┘
重构 x̂

VAE 损失函数 (VAE Loss Function):

\[ \mathcal{L}(\theta, \phi; x) = \mathbb{E}_{q_\phi(z|x)}[\log p_\theta(x|z)] - \text{KL}(q_\phi(z|x) || p(z)) \]

🔑 关键术语对照表 (Glossary)

English 中文 定义
Bayesian statistics 贝叶斯统计 使用贝叶斯定理进行统计推断
Posterior distribution 后验分布 给定数据后参数的概率分布
Prior distribution 先验分布 观测数据前参数的概率分布
Likelihood 似然 给定参数下数据的概率
Conjugate prior 共轭先验 产生同族后验的先验
MCMC MCMC 马尔可夫链蒙特卡洛采样
Metropolis-Hastings Metropolis-Hastings 通用 MCMC 算法
Gibbs sampling Gibbs 采样 从条件分布采样的 MCMC
Hamiltonian Monte Carlo HMC 使用动力学的 MCMC
Bayes factor 贝叶斯因子 模型证据之比
Model evidence 模型证据 边缘似然 P(D|M)
Variational inference 变分推断 优化近似分布的方法
ELBO ELBO 证据下界
Mean-field approximation 平均场近似 因子分解的变分族
VAE VAE 变分自编码器

编译完成时间: 2026-06-01
来源: Wikipedia Bayesian statistics, Bayesian inference, MCMC, Variational inference 等条目
关联文档: statistics-concepts-zh-en.md


**维基百科贝叶斯统计概念 | 中英对照版** [返回顶部](#目录-table-of-contents)