# 随机模拟

随机模拟是一种计算方法，它生成系统的随机样本路径，并从所得输出中估计性能度量或期望。当所关心的量在数学上难以处理，或不存在误差有界的数值近似时，就会使用它，例如在排队网络、化学反应网络、金融风险模型和中子输运中。<sup>[1](https://people.orie.cornell.edu/shane/pubs/StochCompSim.pdf)</sup><sup> • </sup><sup>[2](https://www.jacobaguirre.com/Foundations%20of%20Stochastic%20Simulation.pdf)</sup> 由于算法输出本身是随机的，因此需要概率和统计工具（如大数定律和中心极限定理）来解释结果。<sup>[3](https://link.springer.com/book/10.1007/978-3-032-01190-9)</sup>

| 关键事实 | 详情 |
|---|---|
| 产生什么 | 对期望或性能度量的随机估计，通过置信区间解释；在假设下可能有概率容差保证，但没有确定性误差界<sup>[4](https://users.jyu.fi/~mvihola/stochsim/notes-2020.pdf)</sup> |
| 误差缩放 | 均方根误差按 \( 1/\sqrt{n} \) 下降；多一位有效数字需要100倍的样本量<sup>[5](https://www.wias-berlin.de/people/bayerc/files/lecture_MC+QMC.pdf)</sup> |
| 维度 | \( O(n^{-1/2}) \) 速率与维度无关，但常数可能随维度指数增长<sup>[4](https://users.jyu.fi/~mvihola/stochsim/notes-2020.pdf)</sup> |
| 起源 | 首次在期刊上出现是1949年尼古拉斯·梅特罗波利斯（Nicholas Metropolis）和S·乌拉姆（S. Ulam）的论文《蒙特卡洛方法》<sup>[6](https://doi.org/10.1080/01621459.1949.10483310)</sup>；名称由梅特罗波利斯建议<sup>[7](https://mcnp.lanl.gov/pdf_files/Article_1987_LAS_Metropolis_125--130.pdf)</sup> |
| 马尔可夫链族 | 梅特罗波利斯、罗森布鲁斯、罗森布鲁斯、泰勒和泰勒（Metropolis, Rosenbluth, Rosenbluth, Teller, and Teller，1953）的玻尔兹曼接受方案，由W·K·黑斯廷斯（W. K. Hastings）在1970年推广<sup>[8](https://doi.org/10.1063/1.1699114)</sup><sup> • </sup><sup>[9](https://doi.org/10.1093/biomet/57.1.97)</sup> |
| 化学动力学 | 丹尼尔·T·吉莱斯皮（Daniel T Gillespie）在1976年报道的随机模拟算法<sup>[10](https://doi.org/10.1016/0021-9991%2876%2990041-3)</sup> |
| 拟蒙特卡洛 | 低差异求积，速率约为 \( O((\log N)^{k} \cdot N^{-1}) \)<sup>[11](https://www.cambridge.org/core/journals/acta-numerica/article/abs/monte-carlo-and-quasimonte-carlo-methods/FE7C779B350CFEA45DB2A4CCB2DA9B5C)</sup> |

## 工作原理

核心对象是期望的样本均值估计量。给定来自分布 \( p \) 的独立抽样 \( X_{1}, \ldots, X_{n} \)，\( E_{p}[f(X)] \) 的蒙特卡洛近似为 \( (1/n) \sum_{k=1}^{n} f(X_{k}) \)。<sup>[4](https://users.jyu.fi/~mvihola/stochsim/notes-2020.pdf)</sup> 该估计量是无偏的，方差为 \( \mathrm{Var}(\hat{I}) = (1/n) \, \mathrm{Var}_{p}[f(X)] \)，并且只要期望有限，强大数定律就保证其相合性。<sup>[4](https://users.jyu.fi/~mvihola/stochsim/notes-2020.pdf)</sup>

来自独立重复的估计的统计不确定性正比于 \( \sqrt{V/n} \)，其中 \( V \) 是量的方差，\( n \) 是重复次数；对于马尔可夫链输出，必须改用自相关调整的长期方差。<sup>[12](https://mcnp.lanl.gov/pdf_files/Article_1987_LAS_Eckhardt_131--141.pdf)</sup> 速率 \( O(n^{-1/2}) \) 与维度无关，这使该方法在高维中稳健，但常数可能指数增长，因此它通常不能克服维数灾难。<sup>[4](https://users.jyu.fi/~mvihola/stochsim/notes-2020.pdf)</sup>

## 如何实施

实践者首先定义模型：输入、其分布，以及将输入映射到输出的系统逻辑。然后从均匀伪随机数生成随机变量，好的生成器很重要：梅森旋转算法（Mersenne twister）仍然是R和Matlab中的默认算法，而Julia默认使用Xoshiro256++算法，NumPy的Generator使用PCG64，种子决定整个序列。<sup>[4](https://users.jyu.fi/~mvihola/stochsim/notes-2020.pdf)</sup>

然后实验作为独立重复运行：\( n \) 次重复的输出是独立同分布的，其平均值估计性能度量。<sup>[1](https://people.orie.cornell.edu/shane/pubs/StochCompSim.pdf)</sup> 在一次重复内，离散事件模拟使用事件日历将时钟从一个事件推进到下一个事件；在每个事件处，系统状态被更新，未来事件被调度，统计量被累积。<sup>[2](https://www.jacobaguirre.com/Foundations%20of%20Stochastic%20Simulation.pdf)</sup> 最后评估估计：由中心极限定理得到标准误，对于马尔可夫链方法，还要去除预热期并进行混合诊断。<sup>[13](https://www2.stat.duke.edu/~sschmid/Courses/Stat376/Papers/GeyerStatSci1992.pdf)</sup>

## 起源

该方法源于20世纪40年代洛斯阿拉莫斯的工作。梅特罗波利斯的历史记述将斯坦尼斯瓦夫·乌拉姆（Stanislaw Ulam）1946年关于坎菲尔德接龙游戏成功概率的问题视为起源，并将约翰·冯·诺伊曼（John von Neumann）1947年3月11日给罗伯特·里希特迈尔（Robert Richtmyer）的信视为对裂变材料中中子扩散的第一个详细统计方法；梅特罗波利斯本人建议了“蒙特卡洛”这个名称，提到乌拉姆的一位叔叔“非得去蒙特卡洛”赌博。<sup>[7](https://mcnp.lanl.gov/pdf_files/Article_1987_LAS_Metropolis_125--130.pdf)</sup>

该方法首次出现在1949年尼古拉斯·梅特罗波利斯和S·乌拉姆发表在《美国统计协会杂志》上的论文《蒙特卡洛方法》中，该文将方法表述为对微分方程和积分微分方程的统计方法。<sup>[6](https://doi.org/10.1080/01621459.1949.10483310)</sup><sup> • </sup><sup>[14](http://www-stat.wharton.upenn.edu/~steele/Courses/900/Library/MCMCHistory.pdf)</sup> 1953年，尼古拉斯·梅特罗波利斯、阿里安娜·W·罗森布鲁斯（Arianna W. Rosenbluth）、马歇尔·N·罗森布鲁斯（Marshall N. Rosenbluth）、奥古斯塔·H·泰勒（Augusta H. Teller）和爱德华·泰勒（Edward Teller）在论文《用快速计算机进行状态方程计算》中，基于在MANIAC上运行的计算，引入了现在称为梅特罗波利斯算法的玻尔兹曼接受方案：降低能量的移动总是被接受，而在正温度T下将能量升高ΔE的移动以概率exp(−ΔE/(kT))被接受，该概率随ΔE增大而减小，随T增大而增大。<sup>[8](https://doi.org/10.1063/1.1699114)</sup><sup> • </sup><sup>[7](https://mcnp.lanl.gov/pdf_files/Article_1987_LAS_Metropolis_125--130.pdf)</sup>

## 变体

**蒙特卡洛与MCMC。** 普通蒙特卡洛抽取独立样本。当直接抽样不可能时，马尔可夫链蒙特卡洛构造一个马尔可夫链，其平稳分布是目标分布。黑斯廷斯1970年发表在《生物计量学》（Biometrika）上的论文提出了梅特罗波利斯等人抽样方法对非对称提议的推广；由于计算仅通过比值 \( p(x')/p(x) \) 依赖于目标密度，因此不需要知道归一化常数。<sup>[9](https://doi.org/10.1093/biomet/57.1.97)</sup><sup> • </sup><sup>[15](https://www.probability.ca/hastings/hastings.pdf)</sup>

**序贯蒙特卡洛。** 这些方法最初称为粒子滤波，是为非线性状态空间模型中的在线推断而构思的；序贯重要性采样和采样/重要性重采样（后者由唐纳德·B·鲁宾（Donald B. Rubin）在1987年报道）奠定了其基础。<sup>[16](https://arxiv.org/html/1903.04797v3)</sup><sup> • </sup><sup>[17](https://doi.org/10.2307/2289460)</sup>

**吉莱斯皮的随机模拟算法。** 对于充分混合的化学系统，化学主方程（每个状态对应一个常微分方程）通常维数太高而无法处理；SSA则模拟样本轨迹，轨迹中各状态出现的频率反映化学主方程给出的相应概率。<sup>[18](https://webhomes.maths.ed.ac.uk/~dhigham/Publications/P74.pdf)</sup> 吉莱斯皮于1976年在《计算物理学杂志》上报道了该方法。<sup>[10](https://doi.org/10.1016/0021-9991%2876%2990041-3)</sup> 在每一步，到下一次反应的等待时间 \( \tau \) 服从均值为 \( 1/a_{0}(x) \) 的指数分布，其中 \( a_{0} \) 是倾向函数之和，反应索引 \( j \) 以概率 \( a_{j}(x)/a_{0}(x) \) 选择；两者独立地从均匀随机数中抽取。<sup>[19](http://www.stat.yale.edu/%7Ejtc5/GeneticNetworksGroup/Gillespie1977.pdf)</sup><sup> • </sup><sup>[20](https://www.dna.caltech.edu/courses/cs191/paperscs191/gillespie1.pdf)</sup>

**重要性采样**从辅助分布 \( q \) 中抽取，该分布覆盖目标的相关支撑，并使用估计量 \( (1/n) \sum_{k=1}^{n} f(Y_{k}) \, p(Y_{k})/q(Y_{k}) \)，它是无偏的；常用的自归一化加权估计量通常是有偏的。<sup>[4](https://users.jyu.fi/~mvihola/stochsim/notes-2020.pdf)</sup> 零方差测度变换无法实现，因为它需要预先知道概率，但它指导可实现变换的选择。<sup>[21](https://www.sciencedirect.com/science/article/abs/pii/S092705070613011X)</sup>

**控制变量**利用与已知期望的变量的相关性。<sup>[5](https://www.wias-berlin.de/people/bayerc/files/lecture_MC+QMC.pdf)</sup> **多层蒙特卡洛**由迈克尔·B·贾尔斯（Michael B. Giles）在2008年报道，它耦合跨离散化层次的估计量，并在随机微分方程（SDE）期望估计中达到复杂度 \( O(\varepsilon^{-2}(\log \varepsilon)^{2}) \)。<sup>[22](https://doi.org/10.1287/opre.1070.0496)</sup><sup> • </sup><sup>[23](https://webhomes.maths.ed.ac.uk/~dhigham/Publications/P100.pdf)</sup>

**拟蒙特卡洛**用确定性低差异序列（如格规则和数字网）替代伪随机数，达到接近 \( O(n^{-1+\epsilon}) \) 的速率，其精度接近蒙特卡洛用大约 \( n^{2} \) 次函数求值所能达到的精度。<sup>[24](https://link.springer.com/article/10.1007/s00780-009-0095-y)</sup><sup> • </sup><sup>[25](https://doi.org/10.1137/0915077)</sup><sup> • </sup><sup>[26](https://www.artowen.su.domains/mc/practicalqmc.pdf)</sup> 随机化QMC构造在保留更好速率的同时恢复误差估计。<sup>[27](https://doi.org/10.1007/978-1-4612-2552-2_19)</sup><sup> • </sup><sup>[26](https://www.artowen.su.domains/mc/practicalqmc.pdf)</sup> 当被积函数能被低维光滑函数之和很好地近似时，QMC效果最好；斯隆（Sloan）和亨里克·沃兹尼亚科夫斯基（Henryk Woźniakowski）分析了此类算法何时对高维积分有效，并且自科温·乔伊（Corwin Joy）、费利姆·P·博伊尔（Phelim P. Boyle）和肯·盛·谭（Ken Seng Tan）1996年的工作以来，QMC已被应用于数值金融。<sup>[24](https://link.springer.com/article/10.1007/s00780-009-0095-y)</sup><sup> • </sup><sup>[28](https://doi.org/10.1006/jcom.1997.0463)</sup><sup> • </sup><sup>[29](https://doi.org/10.1287/mnsc.42.6.926)</sup>

## 应用

最初的应用是物理方面的：洛斯阿拉莫斯武器工作的中子输运，以及后来通过梅特罗波利斯算法对构型的采样进行的平衡态统计力学。<sup>[30](https://discover.lanl.gov/publications/actinide-research-quarterly/first-quarter-2023/hitting-the-jackpot-the-birth-of-the-monte-carlo-method)</sup><sup> • </sup><sup>[8](https://doi.org/10.1063/1.1699114)</sup> 在化学和系统生物学中，SSA及其近似模拟基因表达噪声。<sup>[19](http://www.stat.yale.edu/%7Ejtc5/GeneticNetworksGroup/Gillespie1977.pdf)</sup> 在金融中，QMC对高维定价被积函数进行积分；帕斯科夫（Paskov）和特劳布（Traub）凭经验发现，维度在数百的被积函数可以被QMC很好地积分。<sup>[26](https://www.artowen.su.domains/mc/practicalqmc.pdf)</sup> 运筹学应用包括排队模型（如G/G/1系统）、制造、军事后勤、运输和通信，它们都共享在负荷、需求、成本和故障的不确定性下评估性能的需求。<sup>[31](https://proceedings.mlr.press/v258/su25a.html)</sup><sup> • </sup><sup>[1](https://people.orie.cornell.edu/shane/pubs/StochCompSim.pdf)</sup> 最近的工作使模拟器可微：可微吉莱斯皮算法用光滑函数近似精确算法的不连续操作，从而可以通过反向传播计算梯度，它已被用于从大肠杆菌（Escherichia coli）的两个启动子的信使RNA表达测量中学习动力学参数，尽管当平滑超参数太小时其梯度在数值上变得不稳定。<sup>[32](https://elifesciences.org/articles/103877)</sup>

## 局限与替代方法

主要成本是 \( 1/\sqrt{n} \) 速率：粗略蒙特卡洛至少需要 \( 10^{6} \) 个样本才能以10%的相对误差估计 \( 10^{-4} \) 量级的概率，这使得诸如飞机碰撞概率之类的极稀有事件在没有方差缩减的情况下不切实际。<sup>[5](https://www.wias-berlin.de/people/bayerc/files/lecture_MC+QMC.pdf)</sup><sup> • </sup><sup>[33](https://www.sciencedirect.com/science/article/abs/pii/S1569190X14001580)</sup> 误差是概率性的，没有确定性界；对于特定运行和样本量，误差可以任意大，大误差概率随 \( n \) 增大而减小。<sup>[5](https://www.wias-berlin.de/people/bayerc/files/lecture_MC+QMC.pdf)</sup><sup> • </sup><sup>[4](https://users.jyu.fi/~mvihola/stochsim/notes-2020.pdf)</sup> 与确定性方法相比，蒙特卡洛的维度无关速率是其优势：基于网格的求积在成本 \( n \) 下的精度表现为 \( n^{-k/d} \)，即维数灾难，金融问题达到约100维，分子动力学达到约 \( 10^{12} \) 维。<sup>[5](https://www.wias-berlin.de/people/bayerc/files/lecture_MC+QMC.pdf)</sup>

## References

1. [Stochastic Computer Simulation (Henderson & Glynn chapter, doi:10.1016/S0927-0507(06)13001-7)](https://people.orie.cornell.edu/shane/pubs/StochCompSim.pdf)
2. [Foundations and Methods of Stochastic Simulation (Nelson, hosted copy)](https://www.jacobaguirre.com/Foundations%20of%20Stochastic%20Simulation.pdf)
3. [Lectures on Monte Carlo Theory (Lorek & Rolski, Springer, 2025)](https://link.springer.com/book/10.1007/978-3-032-01190-9)
4. [Lectures on stochastic simulation (Vihola, Univ. of Jyväskylä)](https://users.jyu.fi/~mvihola/stochsim/notes-2020.pdf)
5. [Computational Finance lecture notes (C. Bayer, WIAS)](https://www.wias-berlin.de/people/bayerc/files/lecture_MC+QMC.pdf)
6. [Nicholas Metropolis, S. Ulam (1949). The Monte Carlo Method. Journal of the American Statistical Association.](https://doi.org/10.1080/01621459.1949.10483310)
7. [The Beginning of the Monte Carlo Method (Metropolis, Los Alamos Science, 1987)](https://mcnp.lanl.gov/pdf_files/Article_1987_LAS_Metropolis_125--130.pdf)
8. [Nicholas Metropolis and colleagues (1953). Equation of State Calculations by Fast Computing Machines. The Journal of Chemical Physics.](https://doi.org/10.1063/1.1699114)
9. [W. K. Hastings (1970). Monte Carlo sampling methods using Markov chains and their applications. Biometrika.](https://doi.org/10.1093/biomet/57.1.97)
10. [A general method for numerically simulating the stochastic time evolution of coupled chemical reactions (Journal of Computational Physics, 1976)](https://doi.org/10.1016/0021-9991%2876%2990041-3)
11. [Monte Carlo and quasi-Monte Carlo methods (Caflisch, Acta Numerica 1998)](https://www.cambridge.org/core/journals/acta-numerica/article/abs/monte-carlo-and-quasimonte-carlo-methods/FE7C779B350CFEA45DB2A4CCB2DA9B5C)
12. [Stan Ulam, John von Neumann, and the Monte Carlo Method (Eckhardt, Los Alamos Science, 1987)](https://mcnp.lanl.gov/pdf_files/Article_1987_LAS_Eckhardt_131--141.pdf)
13. [Practical Markov Chain Monte Carlo (Geyer, 1992, Statistical Science 7(4):473–511)](https://www2.stat.duke.edu/~sschmid/Courses/Stat376/Papers/GeyerStatSci1992.pdf)
14. [The Evolution of Markov Chain Monte Carlo Methods](http://www-stat.wharton.upenn.edu/~steele/Courses/900/Library/MCMCHistory.pdf)
15. [Monte Carlo sampling methods using Markov chains and their applications (Hastings, 1970, Biometrika)](https://www.probability.ca/hastings/hastings.pdf)
16. [Elements of Sequential Monte Carlo (Naesseth, Lindsten, Schön)](https://arxiv.org/html/1903.04797v3)
17. [Donald B. Rubin (1987). The Calculation of Posterior Distributions by Data Augmentation: Comment: A Noniterative Sampling/Importance Resampling Alternative to the Data Augmentation Algorithm for Creating a Few Imputations When Fractions of Missing Information Are Modest: The SIR Algorithm. Journal of the American Statistical Association.](https://doi.org/10.2307/2289460)
18. [Modeling and Simulating Chemical Reactions (Higham, SIAM Review 50(2), 2008)](https://webhomes.maths.ed.ac.uk/~dhigham/Publications/P74.pdf)
19. [Exact Stochastic Simulation of Coupled Chemical Reactions (Gillespie, J. Phys. Chem. 1977)](http://www.stat.yale.edu/%7Ejtc5/GeneticNetworksGroup/Gillespie1977.pdf)
20. [Stochastic Simulation of Chemical Kinetics (Gillespie, Annual Review of Physical Chemistry 2007)](https://www.dna.caltech.edu/courses/cs191/paperscs191/gillespie1.pdf)
21. [Chapter 11: Rare-Event Simulation Techniques: An Introduction and Recent Advances (Handbook in OR & Management Science)](https://www.sciencedirect.com/science/article/abs/pii/S092705070613011X)
22. [Michael B. Giles (2008). Multilevel Monte Carlo Path Simulation. Operations Research.](https://doi.org/10.1287/opre.1070.0496)
23. [Stochastic ordinary differential equations in applied and computational mathematics (Higham)](https://webhomes.maths.ed.ac.uk/~dhigham/Publications/P100.pdf)
24. [Quasi-Monte Carlo methods with applications in finance (L'Ecuyer & Lemieux, Finance and Stochastics)](https://link.springer.com/article/10.1007/s00780-009-0095-y)
25. [William J. Morokoff, Russel E. Caflisch (1994). Quasi-Random Sequences and Their Discrepancies. SIAM Journal on Scientific Computing.](https://doi.org/10.1137/0915077)
26. [Practical quasi-Monte Carlo integration (Art Owen, online book chapters)](https://www.artowen.su.domains/mc/practicalqmc.pdf)
27. [Art B. Owen (1995). Randomly Permuted (t,m,s)-Nets and (t, s)-Sequences. Lecture notes in statistics.](https://doi.org/10.1007/978-1-4612-2552-2_19)
28. [Ian H Sloan, Henryk Woźniakowski (1998). When Are Quasi-Monte Carlo Algorithms Efficient for High Dimensional Integrals?. Journal of Complexity.](https://doi.org/10.1006/jcom.1997.0463)
29. [Corwin Joy, Phelim P. Boyle, Ken Seng Tan (1996). Quasi-Monte Carlo Methods in Numerical Finance. Management Science.](https://doi.org/10.1287/mnsc.42.6.926)
30. [Hitting the Jackpot: The Birth of the Monte Carlo Method (Los Alamos National Laboratory, 2023)](https://discover.lanl.gov/publications/actinide-research-quarterly/first-quarter-2023/hitting-the-jackpot-the-birth-of-the-monte-carlo-method)
31. [Differentiable Calibration of Inexact Stochastic Simulation Models via Kernel Score Minimization (Su & Klabjan, AISTATS 2025)](https://proceedings.mlr.press/v258/su25a.html)
32. [A differentiable Gillespie algorithm for simulating chemical kinetics, parameter estimation, and designing synthetic biological circuits](https://elifesciences.org/articles/103877)
33. [A survey of rare event simulation methods for static input–output models (Reliability Engineering & System Safety)](https://www.sciencedirect.com/science/article/abs/pii/S1569190X14001580)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Stochastic processes

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/stochastic-simulation

English original: https://www.edgepedia.org/stochastic-simulation
