# 随机计算

随机计算（SC）是一种计算范式，它把数表示为随机比特流中 1 的概率，并用普通逻辑门处理这些流，因此单个与门就能充当乘法器。它用长比特流换取极其简单的算术电路，使其在信号处理、纠错和神经网络加速中的低功耗、低精度硬件上颇具吸引力。<sup>[1](https://dl.acm.org/doi/10.1145/2465787.2465794)</sup><sup> • </sup><sup>[2](https://par.nsf.gov/servlets/purl/10415031)</sup>

| 关键事实 | 详情 |
|---|---|
| 数字格式 | 实数 x∈[0,1] 被表示为比特流，其中每一位以概率 x 为 1；双极性格式用值为 2p−1 的比特流表示 x∈[−1,1]<sup>[2](https://par.nsf.gov/servlets/purl/10415031)</sup> |
| 门级算术 | 与门对单极性流做乘法；同或门对双极性流做乘法；选择器概率为 0.5 的 2 选 1 多路复用器（MUX）执行缩放加法<sup>[2](https://par.nsf.gov/servlets/purl/10415031)</sup> |
| 精度代价 | 长度为 n 的流具有 log2 n 比特的分辨率，即可表示值的间距为 1/n；每增加一比特精度，流长度翻倍（8 比特分辨率需要 256 比特）<sup>[3](https://homes.cs.washington.edu/~armin/DATE_2014.pdf)</sup> |
| 主要开销 | 随机数生成器（比较器加线性反馈移位寄存器（LFSR）或 Sobol 源）在已报道设计中可占电路面积的 80%<sup>[4](http://www.ece.ualberta.ca/~jhan8/publications/TNANO_SCSurvey2024.pdf)</sup> |
| 起源 | 20 世纪 60 年代初，伊利诺伊大学（University of Illinois）的塞尔吉奥·里贝罗（Sergio Ribeiro）与特德·波佩尔鲍姆（Ted Poppelbaum），以及英国标准电信实验室（Standard Telecommunication Laboratories）的布赖恩·盖恩斯（Brian Gaines），各自独立提出<sup>[5](https://gaines.library.uvic.ca/pdf/OriginsSC2019.pdf)</sup> |
| 主要应用 | 低密度奇偶校验（LDPC）解码、图像处理（边缘检测）和神经网络加速器<sup>[1](https://dl.acm.org/doi/10.1145/2465787.2465794)</sup> |
| 主要缺点 | 每增加一比特精度，流长度和计算时间都需指数增长；输入相关性会造成很大的算术误差<sup>[3](https://homes.cs.washington.edu/~armin/DATE_2014.pdf)</sup><sup> • </sup><sup>[1](https://dl.acm.org/doi/10.1145/2465787.2465794)</sup> |

## 工作原理

随机数（SN）是一串随机比特，其值为 1 出现的概率。8 比特中有四个 1 的流编码 4/8。<sup>[6](https://gc.sjtu.edu.cn/~wkqian/papers/Zhao_Qian_A_General_Design_of_Stochastic_Circuit_and_Its_Synthesis.pdf)</sup> 在单极性格式中，值为 p；在双极性格式中，值为 2p−1，因此可以表示负数。<sup>[2](https://par.nsf.gov/servlets/purl/10415031)</sup>

门级算术由概率推出。对于不相关的单极性输入，与门以概率 P(Z=1)=p_X·p_Y 输出 1，因此该门执行乘法。<sup>[2](https://par.nsf.gov/servlets/purl/10415031)</sup> 等价地，与门通过向单位正方形中随机投点来估计其中的矩形面积 p1·p2，这是一种蒙特卡洛估计。<sup>[7](http://www.ece.ualberta.ca/~jhan8/publications/IEEE_CASM_202007282312.pdf)</sup> 对于双极性流，[同或门](https://www.edgepedia.org/zh/xnor-gate)就是乘法器。<sup>[2](https://par.nsf.gov/servlets/purl/10415031)</sup>

[相关性](https://www.edgepedia.org/zh/correlation)是核心注意事项。若两个流都表示 1/2 但彼此相关，例如完全相同，则它们的与门输出为 1/2，而不是正确的 1/4。<sup>[1](https://dl.acm.org/doi/10.1145/2465787.2465794)</sup> 相关性用随机计算相关系数（SCC）量化；不相关流的 SCC 为 0，最大正相关或负相关为 ±1。<sup>[4](http://www.ece.ualberta.ca/~jhan8/publications/TNANO_SCSurvey2024.pdf)</sup> 加法用 2 选 1 多路复用器完成，其选择流概率为 0.5，得到缩放和 c = s·a + (1−s)·b；该操作对其数据输入之间的相关性不敏感。<sup>[2](https://par.nsf.gov/servlets/purl/10415031)</sup><sup> • </sup><sup>[8](https://journals.tubitak.gov.tr/cgi/viewcontent.cgi?article=1777&context=elektrik)</sup>

## 如何实现

设计者将算法映射到随机硬件时，遵循以下步骤：

1. **选择编码。** 非负值用单极性，有符号值用双极性；扩展随机逻辑将范围拓宽，但硬件规模约翻倍。<sup>[4](http://www.ece.ualberta.ca/~jhan8/publications/TNANO_SCSurvey2024.pdf)</sup>
2. **转换输入。** 随机数生成器（SNG）将二进制输入与伪随机源比较，伪随机源通常是 [LFSR](https://www.edgepedia.org/zh/linear-feedback-shift-register) 或 Sobol 序列生成器。<sup>[3](https://homes.cs.washington.edu/~armin/DATE_2014.pdf)</sup> SNG 体积大且数量多，因此共享种子或使用并行 LFSR 很重要。<sup>[9](https://www.mdpi.com/2079-9292/12/7/1749)</sup>
3. **将运算映射到门和状态机。** 乘法变成与门或同或门，加法变成多路复用器网络，tanh 和指数等非线性函数用有限状态机马尔可夫链电路实现。<sup>[9](https://www.mdpi.com/2079-9292/12/7/1749)</sup><sup> • </sup><sup>[10](https://cctbio.ece.umn.edu/wiki/images/4/4e/Li_Lilja_Qian_Bazargan_Riedel_The_Synthesis_of_Complex_Arithmetic_Computation_on_Stochastic_Bit_Streams_Using_Sequential_Logic.pdf)</sup>
4. **管理相关性。** 技术包括共享 RNG，以及流内相关器和去相关器电路（CORLD-C 和 CORLD-D），它们调整相关性并输出低差异流，而无需重新生成流。<sup>[8](https://journals.tubitak.gov.tr/cgi/viewcontent.cgi?article=1777&context=elektrik)</sup><sup> • </sup><sup>[11](https://par.nsf.gov/servlets/purl/10656846)</sup>
5. **将输出转换回二进制。** 计数器或 ADDIE 风格的带反馈积分器将概率转换为并行数；ADDIE 充当随机表示与数值表示之间的接口。<sup>[12](https://computarium.lcd.lu/library/PDF/GAINES_1969_Stochastic_Computing_Systems.pdf)</sup>

## 起源

标准电信实验室（STL）的主要阐述《随机计算》描述了一种估计概率的平滑与存储设备，即 自适应数字元件（ADDIE）。<sup>[13](https://gaines.library.uvic.ca/pdf/SJCC67.pdf)</sup> 伊利诺伊小组的主要论文是《随机计算元件与系统》（Stochastic computing elements and systems），发表于 AFIPS '67 Fall；该文主张，随机脉冲序列把[乘法](https://www.edgepedia.org/zh/multiplication)简化为数字与门，把求和简化为受限的、近似的基于或门的组合，从而降低计算设备成本。<sup>[14](https://dl.acm.org/doi/10.1145/1465611.1465696)</sup> 伊利诺伊小组起初把他们的机器称为“噪声计算机”，后来采用“随机计算机”这一术语。<sup>[5](https://gaines.library.uvic.ca/pdf/OriginsSC2019.pdf)</sup> 盖恩斯 1969 年的专著章节《随机计算系统》（Stochastic Computing Systems）仍是早期最全面的论述。<sup>[12](https://computarium.lcd.lu/library/PDF/GAINES_1969_Stochastic_Computing_Systems.pdf)</sup> 埃施（Esch）1969 年的 RASCEL 是一台可编程模拟计算机，由随机计算元件组成的规则阵列构成。<sup>[5](https://gaines.library.uvic.ca/pdf/OriginsSC2019.pdf)</sup> 在图卢兹（Toulouse）举行的随机计算国际研讨会之后，兴趣骤然消退，因为二进制电路变得更小、更便宜、更快、更可靠。<sup>[1](https://dl.acm.org/doi/10.1145/2465787.2465794)</sup>

## 变体

**双极性与扩展编码。** 盖恩斯引入的双极性映射 y = 2x − 1 使同或门能够对有符号值做乘法。<sup>[1](https://dl.acm.org/doi/10.1145/2465787.2465794)</sup> 扩展随机逻辑将单极性范围从 [0,1] 扩展到 [0, N/2]，将双极性范围扩展到 (−N/2, N/2)，硬件规模约为两倍。<sup>[4](http://www.ece.ualberta.ca/~jhan8/publications/TNANO_SCSurvey2024.pdf)</sup>

**确定性与低差异方法。** 用借自蒙特卡洛方法的低差异序列替代 LFSR 伪随机源，可获得更快、更准确的设计。<sup>[3](https://homes.cs.washington.edu/~armin/DATE_2014.pdf)</sup> 基于计数的设计用计数器和基于 FSM 的生成器替代与门；CBSC 乘法器是后来缩放型和快速型基于计数的除法器的基础。<sup>[15](https://par.nsf.gov/servlets/purl/10542851)</sup>

**加法器与函数合成。** 累加型并行计数器比多路复用器树加法器更准确，后者在数百个输入时表现很差，但前者占用更多面积；并行采样加法器以一半面积达到 APC（累加型并行计数器）的精度。<sup>[2](https://par.nsf.gov/servlets/purl/10415031)</sup> 基于 FSM 的计算元件实现 tanh 和指数运算<sup>[10](https://cctbio.ece.umn.edu/wiki/images/4/4e/Li_Lilja_Qian_Bazargan_Riedel_The_Synthesis_of_Complex_Arithmetic_Computation_on_Stochastic_Bit_Streams_Using_Sequential_Logic.pdf)</sup>，后来的合成方法将目标函数转换为[伯恩斯坦多项式](https://www.edgepedia.org/zh/bernstein-polynomials)，或使用谱变换。<sup>[6](https://gc.sjtu.edu.cn/~wkqian/papers/Zhao_Qian_A_General_Design_of_Stochastic_Circuit_and_Its_Synthesis.pdf)</sup>

**动态与混合随机计算。** 动态随机计算让流中的每一位携带不同的概率，适合基于积分器的算法，如常微分方程（ODE）求解和梯度下降。<sup>[7](http://www.ece.ualberta.ca/~jhan8/publications/IEEE_CASM_202007282312.pdf)</sup> 混合随机-二进制设计在误差会累积的地方保留精确二进制算术：ReSCom 脉冲加速器只对神经元乘法应用随机计算，加法仍用定点数。<sup>[16](https://arxiv.org/html/2606.13560)</sup>

## 应用

**低密度奇偶校验（LDPC）解码。** 高德（Gaudet）与拉普利（Rapley）2003 年的迭代随机解码器每条边使用 1 比特消息，相比多比特全并行解码器大幅减少布线。<sup>[17](https://doi.org/10.1049/el:20030217)</sup><sup> • </sup><sup>[18](https://www.design-reuse.com/article/59479-stochastic-computation-applied-to-the-design-of-error-correcting-decoders/)</sup> LDPC 码用于 WiFi、WiMAX、DVB-S2 和 10 GbE。<sup>[18](https://www.design-reuse.com/article/59479-stochastic-computation-applied-to-the-design-of-error-correcting-decoders/)</sup>

**图像处理。** 一种采用线交换 LFSR 生成的索贝尔（Sobel）边缘检测设计，相比精确二进制方法，面积减少 64%，功耗降低 96%。<sup>[19](https://www.mdpi.com/2079-9292/8/6/720)</sup>

**神经网络。** SC-DCNN 展示了在随机硬件上进行深度卷积神经网络（CNN）推理<sup>[20](https://doi.org/10.48550/arxiv.1611.05939)</sup>，随后出现了积分随机计算。<sup>[21](https://doi.org/10.1109/tvlsi.2017.2654298)</sup>

## 局限与替代方案

**精度与延迟。** 长度为 n 的流携带 log2 n 比特精度，因此每增加一比特精度，流长度翻倍。<sup>[3](https://homes.cs.washington.edu/~armin/DATE_2014.pdf)</sup> 渐近地，误差为 ε 的随机乘法需要 O(1/ε²) 次与门调用，而定点乘法需要 O(log²(1/ε))，因此定点复杂度更低，且精度越高差距越大。<sup>[22](http://vlsi.cornell.edu/~rajit/ps/stochastic.pdf)</sup>

**相关性与小输入误差。** 相关输入会破坏乘法；当两个 8 比特输入都位于 [1/256, 15/256] 时，相对误差可达 100%；缩放型基于计数的乘法将该峰值误差降至 1.8%。<sup>[23](https://par.nsf.gov/servlets/purl/10393030)</sup> 补救措施包括流内相关器和去相关器。<sup>[11](https://par.nsf.gov/servlets/purl/10656846)</sup>

**转换开销。** 在许多设计中 SNG 占据主要面积<sup>[4](http://www.ece.ualberta.ca/~jhan8/publications/TNANO_SCSurvey2024.pdf)</sup>，不过模拟到随机转换的成本约为 100 pJ，远低于计算每幅图像所消耗的数百 nJ。<sup>[24](https://homes.cs.washington.edu/%7Eluisceze/publications/scnn-date17.pdf)</sup>

**与二进制的比较。** 在 65 nm 台积电（TSMC）工艺下，一种混合随机-二进制 CNN 在 8 比特精度时与二进制设计的能效持平，在 4 比特精度时能效是二进制设计的 9.8 倍，但在 4 比特精度时面积是二进制设计的 2 倍。<sup>[24](https://homes.cs.washington.edu/%7Eluisceze/publications/scnn-date17.pdf)</sup> 因此，随机计算适合低精度、受门数限制的工作负载，而非高精度算术。

## References

1. [Survey of Stochastic Computing (Alaghi & Hayes, ACM TECS 2013)](https://dl.acm.org/doi/10.1145/2465787.2465794)
2. [Design of Large-Scale Stochastic Computing (Baker & Hayes, University of Michigan)](https://par.nsf.gov/servlets/purl/10415031)
3. [Fast and Accurate Computation using Stochastic Circuits (Alaghi & Hayes, DATE 2014)](https://homes.cs.washington.edu/~armin/DATE_2014.pdf)
4. [From Multipliers to Integrators: a Survey of Stochastic Computing (IEEE Trans. Nanotechnology, 2024)](http://www.ece.ualberta.ca/~jhan8/publications/TNANO_SCSurvey2024.pdf)
5. [Origins of Stochastic Computing (B. R. Gaines, 2019)](https://gaines.library.uvic.ca/pdf/OriginsSC2019.pdf)
6. [A General Design of Stochastic Circuit and Its Synthesis (Zhao & Qian)](https://gc.sjtu.edu.cn/~wkqian/papers/Zhao_Qian_A_General_Design_of_Stochastic_Circuit_and_Its_Synthesis.pdf)
7. [Introduction to Dynamic Stochastic Computing (DSC) (IEEE Circuits and Systems Magazine)](http://www.ece.ualberta.ca/~jhan8/publications/IEEE_CASM_202007282312.pdf)
8. [Accurate and compact stochastic computations by exploiting correlation (TÜBİTAK Electrical Engineering journal)](https://journals.tubitak.gov.tr/cgi/viewcontent.cgi?article=1777&context=elektrik)
9. [Parallel Stochastic Computing Architecture for Computationally Intensive Applications (Electronics 2023)](https://www.mdpi.com/2079-9292/12/7/1749)
10. [The Synthesis of Complex Arithmetic Computation on Stochastic Bit Streams Using Sequential Logic (ICCAD 2012)](https://cctbio.ece.umn.edu/wiki/images/4/4e/Li_Lilja_Qian_Bazargan_Riedel_The_Synthesis_of_Complex_Arithmetic_Computation_on_Stochastic_Bit_Streams_Using_Sequential_Logic.pdf)
11. [ECO: Enhanced In-Stream Correlation Manipulation for Low-Discrepancy Stochastic Computing (NSF PAR)](https://par.nsf.gov/servlets/purl/10656846)
12. [Stochastic Computing Systems (B. R. Gaines, Advances in Information Systems Science, 1969)](https://computarium.lcd.lu/library/PDF/GAINES_1969_Stochastic_Computing_Systems.pdf)
13. [Stochastic computing (B. R. Gaines, AFIPS Spring Joint Computer Conference 1967)](https://gaines.library.uvic.ca/pdf/SJCC67.pdf)
14. [Stochastic computing elements and systems (Poppelbaum, Afuso, Esch, AFIPS Fall 1967)](https://dl.acm.org/doi/10.1145/1465611.1465696)
15. [Fast and Scaled Counting-Based Stochastic Dividers (CBDIV/FSCDIV)](https://par.nsf.gov/servlets/purl/10542851)
16. [ReSCom: A Reconfigurable Spiking Neural Network Accelerator Using Stochastic Computing (arXiv, 2026)](https://arxiv.org/html/2606.13560)
17. [V.C. Gaudet, A.C. Rapley (2003). Iterative decoding using stochastic computation. Electronics Letters.](https://doi.org/10.1049/el:20030217)
18. [Stochastic Computation applied to the design of Error Correcting Decoders (Gaudet & Rapley, design-reuse.com)](https://www.design-reuse.com/article/59479-stochastic-computation-applied-to-the-design-of-error-correcting-decoders/)
19. [Novel Stochastic Computing for Energy-Efficient Image Processors (Electronics 2019)](https://www.mdpi.com/2079-9292/8/6/720)
20. [Ren, Ao and colleagues (2016). SC-DCNN: Highly-Scalable Deep Convolutional Neural Network using Stochastic Computing. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1611.05939)
21. [Arash Ardakani and colleagues (2017). VLSI Implementation of Deep Neural Network Using Integral Stochastic Computing. IEEE Transactions on Very Large Scale Integration (VLSI) Systems.](https://doi.org/10.1109/tvlsi.2017.2654298)
22. [Comparing Stochastic and Deterministic Computing (Tiwari group, Cornell)](http://vlsi.cornell.edu/~rajit/ps/stochastic.pdf)
23. [Scaled-CBSC: Scaled Counting-Based Stochastic Computing Multiplication for Improved Accuracy](https://par.nsf.gov/servlets/purl/10393030)
24. [Energy-Efficient Hybrid Stochastic-Binary Neural Networks for Near-Sensor Computing (DATE 2017)](https://homes.cs.washington.edu/%7Eluisceze/publications/scnn-date17.pdf)

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

Topic: 技术与人造世界 › 计算技术与数字系统 › 计算机硬件

Copyright 2026 Edgepedia

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

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

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