# 吉莱斯皮算法

**吉莱斯皮算法**（Gillespie algorithm），正式名称为随机模拟算法（stochastic simulation algorithm, SSA），是一种蒙特卡洛方法。它通过逐个模拟每个反应事件——一次一个——并使用严格推导出的随机等待时间，生成充分混合的化学反应系统的统计上精确的样本轨迹<sup>[1](https://apice.unibo.it/bin/view/Publication/StochasticsimulationJphyschem81)</sup>。丹尼尔·T·吉莱斯皮（Daniel T. Gillespie）于1976年在《计算物理学杂志》上提出该算法，并于1977年在《物理化学杂志》上以《耦合化学反应的精确随机模拟》为题给出完整表述<sup>[1](https://apice.unibo.it/bin/view/Publication/StochasticsimulationJphyschem81)</sup><sup> • </sup><sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC2664303/)</sup>。它是采样化学主方程（chemical master equation, CME）轨迹的标准方法；CME 是支配给定时刻各物种具有指定分子数的概率的方程<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC6677717/)</sup>。

| 关键事实 | 细节 |
|---|---|
| 原始论文 | 吉莱斯皮，《计算物理学杂志》22:403–434（1976）和《物理化学杂志》81(25):2340–2361（1977年12月）<sup>[1](https://apice.unibo.it/bin/view/Publication/StochasticsimulationJphyschem81)</sup><sup> • </sup><sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC2664303/)</sup> |
| 产出 | 化学主方程的统计上精确的轨迹，利用反应间等待时间服从指数分布这一事实<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC6677717/)</sup> |
| 核心假设 | 系统是“充分混合”的，因此其状态完全由各物种的整数分子数描述<sup>[4](https://pmc.ncbi.nlm.nih.gov/articles/PMC3492891/)</sup> |
| 直接法步骤 | 抽取两个均匀随机数；下一反应时间为 \( \tau = (1/a_0) \ln(1/r_1) \)，反应编号为使 \( \sum_{j=1}^{\mu} a_j > r_2 a_0 \) 成立的最小 \( \mu \)<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC5425731/)</sup> |
| 主要代价 | SSA 必须模拟每个反应事件，因此当分子数很大或反应很快时，代价变得难以承受<sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC2664303/)</sup> |
| 主要加速方法 | τ跳跃法（吉莱斯皮，2001），一种近似方法，跳跃时间 \( \tau \) 并估计每个反应发生的次数<sup>[6](https://pmc.ncbi.nlm.nih.gov/articles/PMC2638628/)</sup> |
| 软件 | COPASI、StochKit、StochPy、Dizzy 及其他模拟器实现直接法、下一反应法或两者<sup>[7](https://pmc.ncbi.nlm.nih.gov/articles/PMC6013266/)</sup> |

## 解决的问题

化学动力学可用两种方式描述：确定性的，用浓度的耦合常微分方程（反应速率方程）；或随机性的，用主方程支配的随机游走过程<sup>[1](https://apice.unibo.it/bin/view/Publication/StochasticsimulationJphyschem81)</sup>。随机表述具有更坚实的物理基础，因为化学物种实际上以整数分子数存在，其动力学表现出随机性；在细胞系统中，某些反应物拷贝数很小，会导致偏离确定性预测，这一点很重要<sup>[4](https://pmc.ncbi.nlm.nih.gov/articles/PMC3492891/)</sup>。然而，主方程通常难以处理：很少有问题有解析解，而且由于其自变量的数量和性质，它不适合在数字计算机上数值求解<sup>[8](https://www.cl.cam.ac.uk/teaching/2526/Bioinfo/papers/DanielGillespie1.pdf)</sup>。通常只有状态数少且反应速率快的系统才值得对 CME 进行数值求解<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC6677717/)</sup>。

吉莱斯皮的洞见在于，无需直接求解主方程也能进行精确的数值计算。采样轨迹通常也比求解 CME 在计算上更容易，因为数值求解的代价随系统可能状态数增长，而采样的代价随反应频率增长<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC6677717/)</sup>。

## 反应概率密度函数

该算法建立在一个推导出的量上。给定 \( t \) 时刻的状态 \( (X_1, \ldots, X_N) \)，要推进系统需要回答两个问题：下一次反应何时发生，以及将发生何种反应<sup>[8](https://www.cl.cam.ac.uk/teaching/2526/Bioinfo/papers/DanielGillespie1.pdf)</sup>？吉莱斯皮定义了反应概率密度函数 \( P(\tau, \mu) \, d\tau \)，即下一次反应发生在区间 \( (t+\tau, t+\tau+d\tau) \) 内且为 \( R_\mu \) 反应的概率<sup>[8](https://www.cl.cam.ac.uk/teaching/2526/Bioinfo/papers/DanielGillespie1.pdf)</sup>。

每个反应通道 \( R_j \) 由状态变化向量 \( \nu_j \) 和倾向函数 \( a_j \) 刻画，其定义为：在当前状态 \( \mathbf{x} \) 下，下一无穷小间隔内发生一次 \( R_j \) 反应的概率为 \( a_j(\mathbf{x}) \, dt \)<sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC2664303/)</sup>。对于反应 \( S_1 + S_2 \to \) 产物，倾向通常取 \( c_j x_1 x_2 \) 的形式；当两个反应物为同一物种时，取 \( c_j \frac{1}{2} x_1 (x_1 - 1) \)<sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC2664303/)</sup>。由非反应性碰撞使分子位置随机化的假设，可得密度为

\[ P(\tau, \mu) = a_\mu \, e^{-a_0 \tau} \quad (0 \le \tau < \infty), \qquad a_0 = \sum_{i=1}^{M} a_i, \]

这是底层物理假设的严格推论<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC5425731/)</sup><sup> • </sup><sup>[8](https://www.cl.cam.ac.uk/teaching/2526/Bioinfo/papers/DanielGillespie1.pdf)</sup>。等价地，下一反应时间 \( \tau \) 是均值为 \( 1/a_0 \) 的指数随机变量，反应编号 \( j \) 是独立的整数随机变量，其点概率为 \( a_j/a_0 \)<sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC2664303/)</sup>。

## 直接法

最常见的实现是直接法，重复以下四步<sup>[9](https://pmc.ncbi.nlm.nih.gov/articles/PMC3656953/)</sup>：

1. 在 \( t \) 时刻状态 \( \mathbf{x} \) 下，计算倾向 \( a_1(\mathbf{x}), \ldots, a_M(\mathbf{x}) \) 及其和 \( a_0(\mathbf{x}) \)。
2. 抽取两个单位区间均匀随机数 \( r_1 \) 和 \( r_2 \)，并令 \( \tau = (1/a_0) \ln(1/r_1) \)<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC5425731/)</sup>。
3. 选择满足 \( \sum_{j=1}^{\mu} a_j > r_2 a_0 \) 的最小整数 \( \mu \) 作为反应编号<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC5425731/)</sup>。
4. 更新 \( t \leftarrow t + \tau \) 和 \( \mathbf{x} \leftarrow \mathbf{x} + \nu_\mu \)，记录状态，返回第1步<sup>[9](https://pmc.ncbi.nlm.nih.gov/articles/PMC3656953/)</sup>。

与数值求解确定性速率方程的做法不同，该算法从不以有限时间步长 \( \Delta t \) 近似无穷小时间增量 \( dt \)<sup>[1](https://apice.unibo.it/bin/view/Publication/StochasticsimulationJphyschem81)</sup>。由于时间被视为连续的，不会把时间浪费在没有反应发生的迭代上，且 \( \tau \) 值序列是精确的<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC5425731/)</sup>。吉莱斯皮在洛特卡模型、布鲁塞尔振子和俄勒冈振子等著名模型系统上演示了该方法<sup>[1](https://apice.unibo.it/bin/view/Publication/StochasticsimulationJphyschem81)</sup>。

## 精确变体与效率

若干表述在统计上等价，但代价不同。吉莱斯皮1976年的论文提出了直接法和第一反应法；直接法通常是两者中更高效的<sup>[9](https://pmc.ncbi.nlm.nih.gov/articles/PMC3656953/)</sup>。迈克尔·A·吉布森（Michael A. Gibson）和杰霍舒亚·布鲁克（Jehoshua Bruck）的下一反应法是一种精确算法，面向多物种、多反应通道的系统：每个模拟事件只使用一个随机数，所需时间与反应数的对数成正比，而不是与反应数本身成正比<sup>[10](https://authors.library.caltech.edu/records/68ta2-vg371)</sup>。它分别跟踪每个反应的下一反应时间，触发时间最小的反应，用优先队列组织反应，并使用依赖图，使只有受已执行反应影响的反应时间被重新计算<sup>[11](https://copasi.org/Support/User_Manual/Methods/Time_Course_Calculation/Stochastic_Simulation/)</sup><sup> • </sup><sup>[12](https://link.springer.com/article/10.1186/1471-2105-9-356)</sup>。在λ噬菌体裂解/溶原模型上，下一反应法所需的操作数约为现有方法标准实现的 1/15<sup>[10](https://authors.library.caltech.edu/records/68ta2-vg371)</sup>。

后来的精确改进包括优化直接法、排序直接法和对数直接法，它们都是数学上等价的表述，性能优于原始 SSA<sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC2664303/)</sup>。一项实现研究发现，使用依赖图技术更新倾向的直接法变体比吉布森和布鲁克算法显著更快<sup>[12](https://link.springer.com/article/10.1186/1471-2105-9-356)</sup>。高效精确 SSA 的开发仍是一个活跃的研究领域，较新的方法包括部分倾向法、基于拒绝的方法和组合-拒绝法<sup>[13](https://pmc.ncbi.nlm.nih.gov/articles/PMC6408336/)</sup>。

## 近似加速：τ跳跃法与混合方法

SSA 的核心局限在于它显式模拟每个反应，当分子数很大或反应很快而产生大量事件时，这会使其变慢<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC6677717/)</sup><sup> • </sup><sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC2664303/)</sup>。2001年，吉莱斯皮提出了τ跳跃法，这是一种近似技术，向前跨越预先选定的时间 \( \tau \)，并估计该区间内每个反应通道发生的次数，选择 \( \tau \) 时使倾向函数几乎保持恒定<sup>[6](https://pmc.ncbi.nlm.nih.gov/articles/PMC2638628/)</sup><sup> • </sup><sup>[12](https://link.springer.com/article/10.1186/1471-2105-9-356)</sup>。跳跃有时会使分子数变为负值，因此曹（Cao）等人后来改进了该方法以避免这种情况；修改后的τ跳跃算法在 \( \tau \) 变得过小时会自动切换到精确 SSA 运行几步<sup>[12](https://link.springer.com/article/10.1186/1471-2105-9-356)</sup>。值得注意的变体包括拉西纳姆（Rathinam）等人针对刚性系统的隐式τ跳跃法、奥热（Auger）等人的 R 跳跃法，以及安德森（Anderson）的无偏跳跃后拒绝程序<sup>[9](https://pmc.ncbi.nlm.nih.gov/articles/PMC3656953/)</sup>。

混合方法将系统分区，用微分方程模拟涉及大量分子的快反应，用 SSA 模拟涉及少量分子的慢反应<sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC2664303/)</sup><sup> • </sup><sup>[12](https://link.springer.com/article/10.1186/1471-2105-9-356)</sup>。一些实现通过系统中分子数的阈值将 SSA 与τ跳跃法结合<sup>[14](https://pmc.ncbi.nlm.nih.gov/articles/PMC4262058/)</sup>。

## 假设与局限

该算法精确模拟充分混合的化学反应系统，其中分子经历的非反应性碰撞远多于反应性碰撞；它不要求热力学平衡<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC5425731/)</sup>。因此，它不容易被改用来模拟扩散、定位或空间异质性<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC5425731/)</sup>。当空间结构重要时，反应-扩散主方程和布朗动力学等模型处于速率方程与分子动力学之间的中间复杂度层次，二者都已被用于研究整个细胞尺度的系统<sup>[15](https://link.springer.com/article/10.1007/s11538-018-0443-1)</sup>。

## 软件

大多数随机模拟器提供直接法和下一反应法两种选择：COPASI、StochPy 和 Dizzy 两者都提供，而 Gillespie2 和 RoadRunner 只使用直接法，SGNS2 只使用下一反应法<sup>[7](https://pmc.ncbi.nlm.nih.gov/articles/PMC6013266/)</sup>。COPASI 是一个支持 SBML 标准的独立应用，实现了吉莱斯皮直接法、吉布森和布鲁克的下一反应法、τ跳跃法、自适应 SSA/τ跳跃法以及混合 SSA/ODE 方案<sup>[16](https://copasi.org/Support/Features/)</sup>。StochKit 软件工具包的开发目的是让实践中的生物学家和化学家能够使用可靠且高效的随机与多尺度模拟<sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC2664303/)</sup>。

## References

1. [Daniel T. Gillespie (1977). Exact Stochastic Simulation of Coupled Chemical Reactions. *The Journal of Physical Chemistry* 81(25):2340–2361.](https://apice.unibo.it/bin/view/Publication/StochasticsimulationJphyschem81)
2. [Algorithms and Software for Stochastic Simulation of Biochemical Reacting Systems. PMC.](https://pmc.ncbi.nlm.nih.gov/articles/PMC2664303/)
3. [Spatial Stochastic Intracellular Kinetics: A Review of Modelling Approaches. PMC.](https://pmc.ncbi.nlm.nih.gov/articles/PMC6677717/)
4. [Discrete Stochastic Simulation Methods for Chemically Reacting Systems. PMC.](https://pmc.ncbi.nlm.nih.gov/articles/PMC3492891/)
5. [Stochastic chemical kinetics: A review of the modelling and simulation approaches. PMC.](https://pmc.ncbi.nlm.nih.gov/articles/PMC5425731/)
6. [Biochemical simulations: stochastic, approximate stochastic and hybrid approaches. PMC.](https://pmc.ncbi.nlm.nih.gov/articles/PMC2638628/)
7. [An Overview of Network-Based and -Free Approaches for Stochastic Simulation of Biochemical Systems. PMC.](https://pmc.ncbi.nlm.nih.gov/articles/PMC6013266/)
8. [Daniel T. Gillespie (1977). Exact stochastic simulation of coupled chemical reactions (PDF).](https://www.cl.cam.ac.uk/teaching/2526/Bioinfo/papers/DanielGillespie1.pdf)
9. [Perspective: Stochastic algorithms for chemical kinetics. PMC.](https://pmc.ncbi.nlm.nih.gov/articles/PMC3656953/)
10. [Gibson, M. A., Bruck, J. Efficient Exact Stochastic Simulation of Chemical Systems with Many Species and Many Channels. CaltechAUTHORS.](https://authors.library.caltech.edu/records/68ta2-vg371)
11. [COPASI User Manual: Stochastic Simulation.](https://copasi.org/Support/User_Manual/Methods/Time_Course_Calculation/Stochastic_Simulation/)
12. [FERN – a Java framework for stochastic simulation and evaluation of reaction networks. BMC Bioinformatics.](https://link.springer.com/article/10.1186/1471-2105-9-356)
13. [Simulation and inference algorithms for stochastic biochemical reaction networks. PMC.](https://pmc.ncbi.nlm.nih.gov/articles/PMC6408336/)
14. [Stochastic simulation in systems biology. PMC.](https://pmc.ncbi.nlm.nih.gov/articles/PMC4262058/)
15. [Spatial Stochastic Intracellular Kinetics: A Review of Modelling Approaches. *Bulletin of Mathematical Biology*.](https://link.springer.com/article/10.1007/s11538-018-0443-1)
16. [copasi:support/features](https://copasi.org/Support/Features/)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Stochastic processes › Markov chains and processes › Continuous-time Markov processes › Construction, uniformization, and simulation of continuous-time Markov processes

Copyright 2026 Edgepedia

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

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

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