# 朗之万算法

朗之万算法是一种马尔可夫链蒙特卡洛（MCMC）方法，它通过模拟过阻尼（无惯性的动力学；运动忽略动量效应）朗之万动力学来从概率分布中抽取样本：每一步都沿着对数密度的梯度移动当前状态，并加入幅度经过校准的高斯噪声。它产生一个状态序列，其分布逐渐逼近目标分布，被广泛应用于贝叶斯统计、数据同化、反问题和机器学习。<sup>[1](https://www.jmlr.org/papers/volume25/23-0139/23-0139.pdf)</sup> 由于每一步都利用梯度信息，其在维度 \( d \) 上的混合代价优于随机游走 Metropolis，后者的代价为 \( O(d) \)。<sup>[2](https://probability.ca/jeff/ftpdir/lang.pdf)</sup>

| 关键事实 | 陈述 |
|---|---|
| ULA 更新 | \( X_{k+1} = X_k - \gamma_{k+1} \nabla U(X_k) + \sqrt{2\gamma_{k+1}}\, Z_{k+1} \)，其中 \( Z_k \) 为独立同分布的 \( d \) 维标准高斯变量<sup>[3](https://alain.perso.math.cnrs.fr/data/paper/bj_2019.pdf)</sup> |
| 目标律 | 驱动 SDE \( dX_t = -\nabla V(X_t)\,dt + \sqrt{2}\,dB_t \) 的平稳分布为 \( \pi \propto \exp(-V) \)<sup>[4](https://bishtref.com/articles/10.1002/cpa.70032)</sup> |
| MALA | 在 ULA 提议基础上加入 Metropolis–黑斯廷斯接受–拒绝步骤，从而消除离散化偏差<sup>[5](https://www.icts.res.in/sites/default/files/paap-2019-08-08-Eric%20Moulines.pdf)</sup> |
| 最优接受率 | 在具有正则性和乘积目标假设的高维标度极限下，渐近最优接受率为 0.574，但这一最优值对任意目标未必成立<sup>[2](https://probability.ca/jeff/ftpdir/lang.pdf)</sup> |
| 维度标度 | MALA 探索 \( N \) 维目标需要 \( O(N^{1/3}) \) 步，而随机游走 Metropolis 需要 \( O(N) \) 步<sup>[2](https://probability.ca/jeff/ftpdir/lang.pdf)</sup> |
| ULA 偏差 | 在步长 \( \gamma \) 下，ULA 的平稳分布与目标分布的距离为 \( O(\sqrt{d \cdot \gamma}) \)<sup>[6](https://jmlr.org/papers/volume25/23-0783/23-0783.pdf)</sup> |
| SGLD | 用小批量估计代替全梯度，并跳过接受–拒绝步骤，从而支持大规模贝叶斯学习<sup>[7](https://proceedings.neurips.cc/paper/2018/file/335cd1b90bfa4ee70b39d08a4ae0cf2d-Paper.pdf)</sup> |

## 工作原理

该方法基于过阻尼朗之万随机微分方程 \( dX_t = -\nabla V(X_t)\,dt + \sqrt{2}\,dB_t \)，其平稳分布为 \( \pi \propto \exp(-V) \)；漂移项将样本拉向高密度区域，而噪声则维持正确的散布范围。<sup>[4](https://bishtref.com/articles/10.1002/cpa.70032)</sup> 等价地，上述 SDE 的漂移为 \( \nabla\log\pi(X_t) \)，当且仅当该过程的密度等于 \( \pi \) 时，该密度才是时间不变的，这正是该扩散以 \( \pi \) 为不变律的原因；若漂移为 \( (1/2)\nabla\log\pi(X_t) \)，则应与单位布朗噪声配对，即 \( dX_t = (1/2)\nabla\log\pi(X_t)\,dt + dB_t \)。<sup>[8](https://ar5iv.labs.arxiv.org/html/1309.2983)</sup> 用欧拉–丸山格式对该扩散进行时间离散，得到状态空间上的马尔可夫链；对数密度的梯度提供漂移项，注入的高斯项提供扩散项。<sup>[9](https://wrap.warwick.ac.uk/id/eprint/52760/1/WRAP_Stuart_euclid.aoap.1353695955.pdf)</sup> 在常数步长 \( \gamma \) 下，在适当的稳定性和正则性条件下，未调整链具有不变分布 \( \pi_\gamma \)，它通常不同于 \( \pi \)，不过这种不变律并非对每个目标和步长都存在；当它存在时，其差异即为离散化偏差。<sup>[3](https://alain.perso.math.cnrs.fr/data/paper/bj_2019.pdf)</sup>

## 实施方法

实践者首先计算对数密度的梯度 \( \nabla\log\pi \)（在贝叶斯工作中则为负对数后验的梯度）。随后每次迭代在当前状态处计算该梯度，构造提议 \( y = x + \gamma \nabla\log\pi(x) + \sqrt{2\gamma}\,Z \)，其中 \( Z \sim N(0, I_N) \)；在 MALA 中，以概率 \( \alpha_\gamma(x,y) = 1 \wedge \frac{q_\gamma(y,x)\pi(y)}{q_\gamma(x,y)\pi(x)} \) 接受 y，其中 \( q_\gamma \) 为高斯提议密度。<sup>[1](https://www.jmlr.org/papers/volume25/23-0139/23-0139.pdf)</sup><sup> • </sup><sup>[10](https://www.hairer.org/papers/mala.pdf)</sup> 在高维标度极限下，平均接受率应调至 0.574。<sup>[2](https://probability.ca/jeff/ftpdir/lang.pdf)</sup> 对于随机梯度版本，理论表明应采用形如 \( \gamma_m \sim m^{-1/3} \) 的递减步长序列，其均方误差以 \( O(m^{-1/3}) \) 的速率下降。<sup>[11](https://jmlr.csail.mit.edu/papers/volume17/teh16a/teh16a.pdf)</sup>

## 起源

过阻尼朗之万动力学的 Metropolis 化离散在化学文献中被称为“Smart MC”，后来在计算统计中作为 MALA 被重新发现。<sup>[12](https://ar5iv.labs.arxiv.org/html/1505.04905)</sup> Metropolis 调整朗之万算法由加雷思·O·罗伯茨（Gareth O. Roberts）和理查德·L·特威迪（Richard L. Tweedie）于 1996 年在《Bernoulli》上提出，论文题为《朗之万分布的指数收敛及其离散近似》。<sup>[13](https://doi.org/10.2307/3318418)</sup> 随机梯度朗之万动力学由马克斯·韦林（Max Welling）和郑义伟（Yee Whye Teh）于 2011 年在 ICML 上提出，论文题为《通过随机梯度朗之万动力学进行贝叶斯学习》；它向随机梯度更新中加入适量的噪声，使得随着步长退火，迭代值收敛到后验样本。<sup>[5](https://www.icts.res.in/sites/default/files/paap-2019-08-08-Eric%20Moulines.pdf)</sup> 面向深度神经网络的预条件随机梯度朗之万动力学由李春源（Chunyuan Li）及其同事于 2015 年在 arXiv 上提出。<sup>[14](https://doi.org/10.48550/arxiv.1512.07666)</sup> FisherMALA 由米哈利斯·K·齐齐亚斯（Michalis K. Titsias）于 2023 年在 arXiv 上提出。<sup>[15](https://doi.org/10.48550/arxiv.2305.14442)</sup>

## 变体

调整和预条件定义了主要的变体家族。MALA 在 ULA 中加入 Metropolis–黑斯廷斯步骤；预条件 MALA 在扩散中插入一个正定矩阵，适用于分量高度相关的目标。<sup>[8](https://ar5iv.labs.arxiv.org/html/1309.2983)</sup> FisherMALA 从梯度历史中学习预条件矩阵；在最优处，预条件子正比于逆 Fisher 信息矩阵 \( I^{-1} \)，其中 \( I = E_{\pi(x)} \nabla\log\pi(x)\nabla\log\pi(x)^\top \)，每次迭代以二次代价 \( O(d^2) \) 更新。<sup>[16](https://papers.nips.cc/paper_files/paper/2023/file/5da6d5818a156791090c875abeca3cf8-Paper-Conference.pdf)</sup><sup> • </sup><sup>[15](https://doi.org/10.48550/arxiv.2305.14442)</sup> 对于大型数据集，SGLD 用无偏小批量估计 \( \nabla U_0 + (N/p)\sum_{i \in S}\nabla U_i \) 代替梯度，并跳过接受–拒绝步骤；<sup>[7](https://proceedings.neurips.cc/paper/2018/file/335cd1b90bfa4ee70b39d08a4ae0cf2d-Paper.pdf)</sup> mSGLD 消除由此产生的步长一阶渐近偏差，<sup>[17](https://jmlr.org/papers/volume17/15-494/15-494.pdf)</sup> 而 SGLDFP 使用以后验众数为参照的控制变量，以关于数据点数的次线性代价降低梯度方差。<sup>[7](https://proceedings.neurips.cc/paper/2018/file/335cd1b90bfa4ee70b39d08a4ae0cf2d-Paper.pdf)</sup> 李春源、陈、卡尔森和卡林将自适应预条件子与 SGLD 结合用于深度神经网络（pSGLD）。<sup>[14](https://doi.org/10.48550/arxiv.1512.07666)</sup> 进一步的变体包括带摩擦参数的动能（欠阻尼）算法，<sup>[18](https://arxiv.org/pdf/2407.09301)</sup> 以及将随机梯度估计与哈密顿动力学耦合的随机梯度哈密顿蒙特卡洛。<sup>[11](https://jmlr.csail.mit.edu/papers/volume17/teh16a/teh16a.pdf)</sup> 受自然梯度下降启发的 Metropolis 调整预条件朗之万算法（MAPLA）以非渐近混合界处理约束空间，<sup>[19](https://arxiv.org/abs/2412.18701)</sup> 而保不变测度的自适应步长仅在数值上必要时缩减步长，并带有涨落–耗散修正项。<sup>[20](https://arxiv.org/html/2403.11993v2)</sup>

## 应用

该算法被描述为抽样概率测度的主力工具之一，用于贝叶斯统计、数据同化、反问题和机器学习。<sup>[1](https://www.jmlr.org/papers/volume25/23-0139/23-0139.pdf)</sup> SGLD 将其扩展到大型数据集上的贝叶斯学习，在那里一次全梯度迭代将花费 \( N \cdot d \) 次梯度评估；小批量形式使后验采样在大规模下变得可行。<sup>[7](https://proceedings.neurips.cc/paper/2018/file/335cd1b90bfa4ee70b39d08a4ae0cf2d-Paper.pdf)</sup> 在生成建模中，由基于评分的生成模型先验驱动的预条件朗之万动力学被用于无限维线性贝叶斯反问题，其漂移项将学习到的神经网络评分与数据拟合梯度相结合。<sup>[21](https://proceedings.neurips.cc/paper_files/paper/2025/file/9aa618b7d721666ca8eadca5d161a1d4-Paper-Conference.pdf)</sup> Metropolis 调整扩散模型（MADM）用接受–拒绝朗之万步骤替换扩散模型采样器中带有偏差的未调整朗之万校正器。<sup>[22](https://arxiv.org/html/2605.09654v1)</sup>

## 局限与替代方法

没有 Metropolis 步骤时，无论步长方差多小，离散朗之万近似都可能具有暂留性，且 ULA 即使对轻尾目标也可能无法收敛；MALA 在适当条件下收敛，但即使扩散指数收敛，它也可能无法以几何速度收敛。<sup>[2](https://probability.ca/jeff/ftpdir/lang.pdf)</sup><sup> • </sup><sup>[13](https://doi.org/10.2307/3318418)</sup><sup> • </sup><sup>[30](https://projecteuclid.org/journals/bernoulli/volume-2/issue-4/Exponential-convergence-of-Langevin-distributions-and-their-discrete-approximations/bj/1178291835.pdf)</sup> 对于非全局利普希茨漂移，即使 SDE 具有谱隙，MALA 也可能缺乏谱隙，不过除去关于步长呈指数小的误差项，收敛仍保持指数速度。<sup>[10](https://www.hairer.org/papers/mala.pdf)</sup> 对于固定精度 \( \varepsilon \)，在瓦瑟斯坦距离或全变差距离下，ULA 需要 \( O(d \cdot \varepsilon^{-2}) \) 或 \( O(d \cdot \varepsilon^{-1}) \) 次迭代（至多相差对数项），具体取决于 U 的光滑性；在 n 次迭代和步长 \( \gamma_n \) 下，瓦瑟斯坦误差为 \( O(n^{-1/2}) \) 或 \( O(n^{-1}) \)。<sup>[3](https://alain.perso.math.cnrs.fr/data/paper/bj_2019.pdf)</sup> 在步长 \( \gamma \) 下，其平稳偏差为 \( O(\sqrt{d \cdot \gamma}) \)。<sup>[6](https://jmlr.org/papers/volume25/23-0783/23-0783.pdf)</sup> 相比之下，在强对数凹情形下，MALA 至多需要 \( \text{poly-log}(1/\varepsilon) \) 次迭代（常数步长）。<sup>[6](https://jmlr.org/papers/volume25/23-0783/23-0783.pdf)</sup> 对于条件数为 \( \kappa \) 的对数凹密度，MALA 达到全变差误差 \( \delta \) 需要 \( O(\kappa \cdot d \log(1/\delta)) \) 步，而 ULA 需要 \( O(\kappa^{2} \cdot d/\delta^{2}) \) 步。<sup>[23](https://proceedings.mlr.press/v75/dwivedi18a/dwivedi18a.pdf)</sup> 尽管 ULA 对完整变量向量的误差随维度缩放较差，但正比于 d 的较低次幂的迭代次数通常足以处理所有 k-边际，这一效应称为偏差去局域化。<sup>[4](https://bishtref.com/articles/10.1002/cpa.70032)</sup> SGLD 继承了子采样问题：当常数步长按 \( 1/N \) 缩放时，其不变测度显著偏离后验，并由于随机梯度的高方差而表现得像 SGD；<sup>[7](https://proceedings.neurips.cc/paper/2018/file/335cd1b90bfa4ee70b39d08a4ae0cf2d-Paper.pdf)</sup> 控制这一偏差迫使步长小到使达到目标精度的代价对所有批量大小大致相同。<sup>[24](https://ar5iv.labs.arxiv.org/html/1706.02692)</sup> 下界表明，存在一些后验，任何 SGLD 算法在平均至少见过每个数据点一次之前，都会返回极差的样本。<sup>[25](https://ar5iv.labs.arxiv.org/html/2412.01952)</sup> 朗之万动力学在高维下对 L^2（更一般地 L^p）评分估计误差也不稳健，即使评分误差指数小，在次指数时间尺度上仍远离目标；达斯等人于 2023 年和黄等人于 2024 年开展的早期工作研究了评分估计的 L-无穷界，而这些界在评分匹配中不会自然出现。<sup>[26](https://arxiv.org/pdf/2603.11319)</sup> 与随机游走 Metropolis 相比，梯度信息将混合的维度依赖性从 \( O(d) \) 改善为 \( O(d^{1/3}) \)。<sup>[6](https://jmlr.org/papers/volume25/23-0783/23-0783.pdf)</sup> 与哈密顿蒙特卡洛相比，已发表的比较是间接的：在已报道的实验中，无偏动能估计器 UBUBU 的效率可比随机化哈密顿蒙特卡洛高 2–3 倍。<sup>[27](https://arxiv.org/abs/2311.05025)</sup> 使用海森矩阵信息的二阶变体在病态情形下优于一阶朗之万蒙特卡洛，<sup>[28](https://arxiv.org/html/1710.00095v4)</sup> 且通过动能变体 KLMC 和 KLMC2，误差界可推广到光滑且对数凹但非强对数凹的目标。<sup>[29](https://arxiv.org/html/1906.08530v3)</sup>

## References

1. [Optimal Scaling for the Proximal Langevin Algorithm in High Dimensions](https://www.jmlr.org/papers/volume25/23-0139/23-0139.pdf)
2. [Optimal Scaling for Various Metropolis-Hastings Algorithms (Roberts & Rosenthal)](https://probability.ca/jeff/ftpdir/lang.pdf)
3. [High-dimensional Bayesian inference via the Unadjusted Langevin Algorithm](https://alain.perso.math.cnrs.fr/data/paper/bj_2019.pdf)
4. [Convergence of Unadjusted Langevin in High Dimensions: Delocalization of Bias](https://bishtref.com/articles/10.1002/cpa.70032)
5. [The Langevin MCMC: Theory and Methods (Moulines lecture notes)](https://www.icts.res.in/sites/default/files/paap-2019-08-08-Eric%20Moulines.pdf)
6. [On the Computational Complexity of Metropolis-Adjusted Langevin Algorithms for Bayesian Posterior Sampling](https://jmlr.org/papers/volume25/23-0783/23-0783.pdf)
7. [The promises and pitfalls of Stochastic Gradient Langevin Dynamics (NeurIPS 2018)](https://proceedings.neurips.cc/paper/2018/file/335cd1b90bfa4ee70b39d08a4ae0cf2d-Paper.pdf)
8. [Langevin diffusions and the Metropolis-adjusted Langevin algorithm](https://ar5iv.labs.arxiv.org/html/1309.2983)
9. [Optimal scaling and diffusion limits for the Langevin algorithm in high dimensions](https://wrap.warwick.ac.uk/id/eprint/52760/1/WRAP_Stuart_euclid.aoap.1353695955.pdf)
10. [Non-asymptotic mixing of the MALA algorithm (Hairer, Stuart, Vollmer)](https://www.hairer.org/papers/mala.pdf)
11. [Consistency and Fluctuations For Stochastic Gradient Langevin Dynamics](https://jmlr.csail.mit.edu/papers/volume17/teh16a/teh16a.pdf)
12. [Improving dynamical properties of metropolized discretizations of overdamped Langevin dynamics](https://ar5iv.labs.arxiv.org/html/1505.04905)
13. [Gareth O. Roberts, Richard L. Tweedie (1996). Exponential Convergence of Langevin Distributions and Their Discrete Approximations. Bernoulli.](https://doi.org/10.2307/3318418)
14. [Li, Chunyuan and colleagues (2015). Preconditioned Stochastic Gradient Langevin Dynamics for Deep Neural Networks. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1512.07666)
15. [Titsias, Michalis K. (2023). Optimal Preconditioning and Fisher Adaptive Langevin Sampling. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2305.14442)
16. [Optimal Preconditioning and Fisher Adaptive Langevin Sampling (FisherMALA)](https://papers.nips.cc/paper_files/paper/2023/file/5da6d5818a156791090c875abeca3cf8-Paper-Conference.pdf)
17. [Exploration of the (Non-)Asymptotic Bias and Variance of Stochastic Gradient Langevin Dynamics](https://jmlr.org/papers/volume17/15-494/15-494.pdf)
18. [Convergence in total variation for the kinetic Langevin algorithm](https://arxiv.org/pdf/2407.09301)
19. [High-accuracy sampling from constrained spaces with the Metropolis-adjusted Preconditioned Langevin Algorithm](https://arxiv.org/abs/2412.18701)
20. [Adaptive stepsize algorithms for Langevin dynamics](https://arxiv.org/html/2403.11993v2)
21. [Preconditioned Langevin Dynamics with Score-Based Generative Models for Infinite-Dimensional Linear Bayesian Inverse Problems](https://proceedings.neurips.cc/paper_files/paper/2025/file/9aa618b7d721666ca8eadca5d161a1d4-Paper-Conference.pdf)
22. [Metropolis-Adjusted Diffusion Models](https://arxiv.org/html/2605.09654v1)
23. [Log-concave sampling: Metropolis-Hastings algorithms are fast! (Dwivedi et al.)](https://proceedings.mlr.press/v75/dwivedi18a/dwivedi18a.pdf)
24. [The True Cost of SGLD](https://ar5iv.labs.arxiv.org/html/1706.02692)
25. [No Free Lunch for Stochastic Gradient Langevin Dynamics (arXiv 2412.01952)](https://ar5iv.labs.arxiv.org/html/2412.01952)
26. [Robustness of Langevin dynamics to score estimation error (lower bounds)](https://arxiv.org/pdf/2603.11319)
27. [Unbiased Kinetic Langevin Monte Carlo with Inexact gradients](https://arxiv.org/abs/2311.05025)
28. [User-friendly guarantees for the Langevin Monte Carlo with inaccurate gradient](https://arxiv.org/html/1710.00095v4)
29. [Bounding the error of discretized Langevin algorithms for non-strongly log-concave targets](https://arxiv.org/html/1906.08530v3)
30. [projecteuclid.org](https://projecteuclid.org/journals/bernoulli/volume-2/issue-4/Exponential-convergence-of-Langevin-distributions-and-their-discrete-approximations/bj/1178291835.pdf)

---
*Initially written Sep 29, 2026 · Reviewed: Sep 30, 2026 · Edited: Sep 30, 2026 · Last review: Sep 30, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Statistical inference, estimation, sampling, and testing

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/langevin-algorithm

English original: https://www.edgepedia.org/langevin-algorithm
