# 伯努利分布

**伯努利分布**（Bernoulli distribution）是单次随机试验的离散概率分布，该试验恰好有两个结果，习惯上标记为1（“成功”）和0（“失败”），其中成功的概率为p，失败的概率为q = 1 − p，且0 < p < 1<sup>[1](https://goldbook.iupac.org/terms/view/09590)</sup>。抛硬币时正反面的分布就是伯努利分布的一个例子<sup>[2](https://mathworld.wolfram.com/BernoulliDistribution.html)</sup>。伯努利试验是一种统计实验，有两个可能的结果，称为成功和失败，成功概率为p<sup>[3](https://gregorkb.github.io/statmeth/part_random_variables/bernoulli_binomial.html)</sup>。

| 关键事实 | 详情 |
|---|---|
| 支撑集与概率质量函数 | X ∈ {0, 1}，P(X = 1) = p，P(X = 0) = 1 − p；紧凑地写为 p(x) = p<sup>x</sup>(1 − p)<sup>1−x</sup>，x ∈ {0, 1}，否则为0<sup> • </sup><sup>[3](https://gregorkb.github.io/statmeth/part_random_variables/bernoulli_binomial.html)</sup><sup> • </sup><sup>[4](https://www.sciencedirect.com/science/article/pii/B9780080448947017218)</sup><sup> • </sup><sup>[27](https://www.mas.ncl.ac.uk/ask/numeracy-maths-statistics/statistics/distributions/bernoulli-distribution.html)</sup> |
| 均值与方差 | E[X] = p；Var(X) = p(1 − p)，在p = 1/2时取最大值1/4，在p = 0或1时为零<sup>[3](https://gregorkb.github.io/statmeth/part_random_variables/bernoulli_binomial.html)</sup><sup> • </sup><sup>[5](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/11%3A_Bernoulli_Trials/11.01%3A_Introduction_to_Bernoulli_Trials)</sup> |
| 矩母函数 | M<sub>X</sub>(t) = pe<sup>t</sup> + q<sup>[6](https://bookdown.org/pkaldunn/DistTheory/DiscreteDistributions.html)</sup> |
| 指数族 | 自然参数η = log(p/(1 − p))（对数几率），统计量T(x) = x，对数配分函数A(η) = log(1 + e<sup>η</sup>)<sup>[7](https://people.eecs.berkeley.edu/~jordan/courses/260-spring10/other-readings/chapter8.pdf)</sup> |
| 共轭先验 | Beta(α, β)；在n次试验中有y次成功后，后验为Beta(α + y, β + n − y)<sup>[8](https://www.stat.purdue.edu/~fmliang/STAT611/st611ch7Bayes.pdf)</sup> |
| 最大似然估计 | 样本中成功的比例<sup>[4](https://www.sciencedirect.com/science/article/pii/B9780080448947017218)</sup> |
| 命名来源 | 雅各布·伯努利（Jakob Bernoulli，1655–1705），其《推测术》（*Ars Conjectandi*，1713）证明了伯努利试验的大数定律<sup>[3](https://gregorkb.github.io/statmeth/part_random_variables/bernoulli_binomial.html)</sup><sup> • </sup><sup>[9](https://www.cambridge.org/core/journals/astin-bulletin-journal-of-the-iaa/article/bernoullis-law-of-large-numbers/103E1519C96A3C1787DFEB777A30DFB2)</sup> |

## 定义与性质

伯努利随机变量X ∼ Ber(p)以概率p取值1，以概率1 − p取值0<sup>[10](https://web.stanford.edu/class/archive/cs/cs109/cs109.1204/lectureNotes/LN07_bernoulli_binomial.pdf)</sup>。概率质量函数可以一行写为p(x) = p<sup>x</sup>(1 − p)<sup>1−x</sup>，x ∈ {0, 1}，否则为0，由此可得E[X] = p，Var(X) = p(1 − p)<sup>[3](https://gregorkb.github.io/statmeth/part_random_variables/bernoulli_binomial.html)</sup><sup> • </sup><sup>[27](https://www.mas.ncl.ac.uk/ask/numeracy-maths-statistics/statistics/distributions/bernoulli-distribution.html)</sup>。方差由E(X²) − [E(X)]² = p − p²得出，因为在支撑集{0, 1}上X² = X<sup>[5](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/11%3A_Bernoulli_Trials/11.01%3A_Introduction_to_Bernoulli_Trials)</sup><sup> • </sup><sup>[11](https://doi.org/10.66147/lapm.20253129)</sup>。

累积分布函数是阶梯函数：x < 0时F(x) = 0，0 ≤ x < 1时F(x) = 1 − p，x ≥ 1时F(x) = 1<sup>[4](https://www.sciencedirect.com/science/article/pii/B9780080448947017218)</sup>。概率生成函数为P(t) = (1 − p) + pt<sup>[5](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/11%3A_Bernoulli_Trials/11.01%3A_Introduction_to_Bernoulli_Trials)</sup>，矩母函数为M<sub>X</sub>(t) = pe<sup>t</sup> + q<sup>[6](https://bookdown.org/pkaldunn/DistTheory/DiscreteDistributions.html)</sup>。

香农熵为H = −p·log<sub>b</sub>(p) − (1 − p)·log<sub>b</sub>(1 − p)<sup>[12](https://www.mdpi.com/2227-7390/10/21/3980)</sup>。方差和熵都在两个结果等概率出现时，即p = 1/2时取最大值，在只有一个结果出现时取最小值<sup>[12](https://www.mdpi.com/2227-7390/10/21/3980)</sup>。方差函数p(1 − p)是一条开口向下的抛物线，在p = 1/2处最大值为1/4，在p = 0或p = 1处最小值为0，此时变量是确定性的<sup>[5](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/11%3A_Bernoulli_Trials/11.01%3A_Introduction_to_Bernoulli_Trials)</sup>。

## 伯努利试验及其假设

一串伯努利试验需要三个条件：每次试验有两个可能的结果，称为成功和失败；各次试验相互独立；每次试验中成功的概率为p，失败的概率为1 − p<sup>[5](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/11%3A_Bernoulli_Trials/11.01%3A_Introduction_to_Bernoulli_Trials)</sup>。《数学百科全书》（Encyclopedia of Mathematics）将同一方案表述为具有恰好两个结果的独立试验，其概率不随试验次数改变，并称之为概率论的主要方案之一<sup>[13](https://encyclopediaofmath.org/wiki/Bernoulli_trials)</sup>。

以此建模的现实现象包括抛硬币、随机二进制数字、磁盘驱动器是否崩溃，以及某人是否喜欢某部Netflix电影<sup>[10](https://web.stanford.edu/class/archive/cs/cs109/cs109.1204/lectureNotes/LN07_bernoulli_binomial.pdf)</sup>。在结构可靠性中，n个独立组件以伯努利试验建模并串联，得到系统可靠性函数r(p) = p<sup>n</sup>，p ∈ [0, 1]<sup>[5](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/11%3A_Bernoulli_Trials/11.01%3A_Introduction_to_Bernoulli_Trials)</sup>。

## 与其他分布的关系

**二项分布。** 若X是n次独立伯努利试验中成功的次数，每次成功概率为p，则X具有二项概率质量函数p(x) = C(n, x) p<sup>x</sup>(1 − p)<sup>n−x</sup><sup> • </sup><sup>[3](https://gregorkb.github.io/statmeth/part_random_variables/bernoulli_binomial.html)</sup>。伯努利分布是二项分布在单次试验时的特例，国际纯粹与应用化学联合会将其描述为对应于随机分布的特例<sup>[1](https://goldbook.iupac.org/terms/view/09590)</sup>。相应地，具有相同成功概率的独立伯努利变量之和服从二项分布<sup>[14](https://d2l.smola.org/chapter_mdl-probability-statistics/mdl-distributions.html)</sup>。当n → ∞时，二项分布可以用正态分布或泊松分布近似<sup>[13](https://encyclopediaofmath.org/wiki/Bernoulli_trials)</sup>。

**几何分布与负二项分布。** 首次成功之前的试验次数服从几何分布，概率为q<sup>k</sup>p；第r次成功之前的失败次数服从负二项分布<sup>[13](https://encyclopediaofmath.org/wiki/Bernoulli_trials)</sup>。在“首次成功前失败次数”的形式下，几何分布的概率质量函数为p<sub>X</sub>(x; p) = q<sup>x</sup>p，x = 0, 1, 2, …，均值为(1 − p)/p，方差为(1 − p)/p²<sup>[6](https://bookdown.org/pkaldunn/DistTheory/DiscreteDistributions.html)</sup>。

**分类分布。** 分类分布将伯努利分布从两个结果推广到K个结果，伯努利分布是K = 2的情形<sup>[14](https://d2l.smola.org/chapter_mdl-probability-statistics/mdl-distributions.html)</sup>。

**指数族。** {0, 1}上的伯努利密度p(x|π) = π^x(1 − π)^(1 − x)是一个典范指数族，自然参数η = log(π/(1 − π))，统计量T(x) = x，对数配分函数A(η) = log(1 + e<sup>η</sup>)<sup>[7](https://people.eecs.berkeley.edu/~jordan/courses/260-spring10/other-readings/chapter8.pdf)</sup><sup> • </sup><sup>[27](https://www.mas.ncl.ac.uk/ask/numeracy-maths-statistics/statistics/distributions/bernoulli-distribution.html)</sup>。

## 参数估计

**最大似然。** 从伯努利变量样本x₁, x₂, …, xₙ中得到的p的最大似然估计是样本均值，即样本中成功的比例<sup>[4](https://www.sciencedirect.com/science/article/pii/B9780080448947017218)</sup>。自然参数的最大似然估计是对应的对数几率<sup>[15](https://www.cs.columbia.edu/~blei/fogm/2016F/doc/exponential_families.pdf)</sup>，均值的最大似然估计达到克拉美–罗下界，因此在这个意义上它是最优估计量<sup>[7](https://people.eecs.berkeley.edu/~jordan/courses/260-spring10/other-readings/chapter8.pdf)</sup>。

当数据中没有成功时，最大似然估计会退化：如果我们看到3次试验全是反面，估计会预测正面的概率为零<sup>[16](https://www.ccs.neu.edu/home/vip/teach/MLcourse/3_generative_models/lecture_notes/Murphy_bernoulli_multinom.pdf)</sup>，这促使人们采用贝叶斯估计。一项关于最大似然估计与贝叶斯估计的比较报告指出，最大似然估计是无偏且一致的，而贝叶斯估计量通过向先验均值收缩，在小样本下获得更低的均方误差<sup>[11](https://doi.org/10.66147/lapm.20253129)</sup>。

**贝叶斯估计。** 若X₁, …, Xₙ服从伯努利(θ)，且θ的先验为Beta(α, β)，则后验为Beta(α + Σxᵢ, β + n − Σxᵢ)；贝塔分布族被称为伯努利分布样本的共轭先验分布族<sup>[8](https://www.stat.purdue.edu/~fmliang/STAT611/st611ch7Bayes.pdf)</sup>。如果一个先验与似然相乘后得到的后验与先验属于同一参数族，则该先验被称为共轭的<sup>[16](https://www.ccs.neu.edu/home/vip/teach/MLcourse/3_generative_models/lecture_notes/Murphy_bernoulli_multinom.pdf)</sup>，并且每个指数族都有共轭先验（迪亚科尼斯和伊尔维萨克，1979）<sup>[15](https://www.cs.columbia.edu/~blei/fogm/2016F/doc/exponential_families.pdf)</sup>。对于客观选择，Beta(1, 1)可作为p ∈ [0, 1]上的无信息均匀先验<sup>[11](https://doi.org/10.66147/lapm.20253129)</sup>。

**样本量。** 以置信度1 − α和误差幅度d估计p所需的样本量n的一个保守估计为n = ⌈z<sub>α</sub>²/(4d²)⌉，其中对于双侧区间z<sub>α</sub> = z(1 − α/2)；因子4对应于p = 1/2时的最大方差1/4<sup>[17](https://www.randomservices.org/random/interval/Bernoulli.html)</sup>。

## 数据解读

方差和熵的穹顶形行为有实际后果。根据中心极限定理，标准得分Z = (M − p)/√(p(1 − p)/n)近似服从标准正态分布，当p接近1/2时其分布最接近正态，当p接近0或1时离正态最远<sup>[17](https://www.randomservices.org/random/interval/Bernoulli.html)</sup>。同样的p = 1/2点也是p(1 − p)取得最大值的地方，因为处处有p(1 − p) ≤ 1/4<sup>[5](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/11%3A_Bernoulli_Trials/11.01%3A_Introduction_to_Bernoulli_Trials)</sup><sup> • </sup><sup>[17](https://www.randomservices.org/random/interval/Bernoulli.html)</sup>。

## 应用

**机器学习分类。** 伯努利负对数似然−y log p̂ − (1 − y) log(1 − p̂)正是二分类中使用的二元交叉熵损失<sup>[14](https://d2l.smola.org/chapter_mdl-probability-statistics/mdl-distributions.html)</sup>。从指数族自然参数到均值的逆映射是逻辑函数，自然参数空间是整个实数轴，这是逻辑回归的统计基础<sup>[7](https://people.eecs.berkeley.edu/~jordan/courses/260-spring10/other-readings/chapter8.pdf)</sup>。

**可靠性。** 失效频率可以用伯努利分布研究，其中P<sub>f</sub>是均值，P<sub>f</sub>(1 − P<sub>f</sub>)是方差<sup>[12](https://www.mdpi.com/2227-7390/10/21/3980)</sup>。

**软件与模拟。** 要生成伯努利随机数，从(0, 1)上的均匀分布中抽取R；若R小于p，则令X为1，否则令X为0<sup>[4](https://www.sciencedirect.com/science/article/pii/B9780080448947017218)</sup>。SciPy以形状参数p（单次成功的概率）实现该分布<sup>[18](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.bernoulli.html)</sup>；PyTorch提供torch.bernoulli，它抽取二进制值，每个输出元素根据输入张量中对应的概率抽取1<sup>[19](https://docs.pytorch.org/docs/2.3/generated/torch.bernoulli.html)</sup>；TensorFlow Probability实现伯努利分布，以probs或logits参数化<sup>[20](https://github.com/tensorflow/probability/blob/master/tensorflow_probability/python/distributions/bernoulli.py)</sup>。

来自深度学习的一个警示：变分自编码器长期将伯努利似然应用于[0, 1]取值的像素数据，连续伯努利分布（continuous Bernoulli distribution）被引入以修补这一错误，产生了更清晰的图像样本并改善了VAE性能<sup>[21](https://proceedings.neurips.cc/paper/2019/file/f82798ec8909d23e55679ee26bb26437-Paper.pdf)</sup>。与伯努利分布不同，连续伯努利的均值不是其参数λ；其归一化常数满足C(λ) ≥ 2，仅当λ = 0.5时取等号<sup>[21](https://proceedings.neurips.cc/paper/2019/file/f82798ec8909d23e55679ee26bb26437-Paper.pdf)</sup>。PyTorch的torch.distributions包含ContinuousBernoulli分布<sup>[22](https://docs.pytorch.org/docs/2.3/_modules/torch/distributions/continuous_bernoulli.html)</sup>。

## 历史

该分布以雅各布·伯努利（Jakob Bernoulli，1655–1705）命名<sup>[3](https://gregorkb.github.io/statmeth/part_random_variables/bernoulli_binomial.html)</sup>。伯努利在1684年至1690年间发展了他关于概率的见解，但他在其中阐述这些见解的《推测术》直到1713年，即他去世八年后才问世<sup>[23](https://bez.unibas.ch/fileadmin/user_upload/bez/The-difficult-birth-of-stochastics-Jacob-Bernoulli-s-Ars-Conjectandi-1713-_2014_Historia-Mathematica.pdf)</sup>；第四部分于1713年出版，此前有1703–1704年与莱布尼茨的通信，出版推迟的可能原因是伯努利无法更精确地计算概率P<sub>N</sub><sup>[24](https://www.probabilityandfinance.com/pulskamp/JakobBernoulli/ars_sung.pdf)</sup>。

在《推测术》第四部分中，伯努利证明了大数定律，这是概率论、统计学和精算学中的基本定理之一<sup>[9](https://www.cambridge.org/core/journals/astin-bulletin-journal-of-the-iaa/article/bernoullis-law-of-large-numbers/103E1519C96A3C1787DFEB777A30DFB2)</sup>。《数学百科全书》称赞他改造了惠更斯的期望演算，使概率成为其主要概念，并表述和证明了弱大数定律，这是现代概率论和统计学的基石；《推测术》这一标题受到《思维术》（*Ars Cogitandi*，更常被称为《波尔罗亚尔逻辑》）的启发<sup>[25](https://encyclopediaofmath.org/wiki/Bernoulli,_Jakob)</sup>。

后来的工作完成了伯努利试验的近似理论：棣莫弗（de Moivre）成功为p = 1/2提供了正态近似，拉普拉斯（Laplace）给出了一般p情形下的正态近似<sup>[24](https://www.probabilityandfinance.com/pulskamp/JakobBernoulli/ars_sung.pdf)</sup>。在数学史上，《推测术》充当了连接惠更斯《论赌博中的计算》（其中处理了赌博中的期望）与亚伯拉罕·棣莫弗在《机遇论》（*The Doctrine of Chances*）中发展的数学概率论的纽带<sup>[26](https://onlinelibrary.wiley.com/doi/10.1111/insr.12050)</sup>。概率论中许多关于独立变量之和的重要定律，包括弱大数定律和强大数定律、重对数律以及中心极限定理，最初都是针对伯努利试验方案建立的<sup>[13](https://encyclopediaofmath.org/wiki/Bernoulli_trials)</sup>。

## References

1. [Bernoullian distribution (09590), IUPAC Gold Book](https://goldbook.iupac.org/terms/view/09590)
2. [Bernoulli Distribution, Wolfram MathWorld](https://mathworld.wolfram.com/BernoulliDistribution.html)
3. [Bernoulli and binomial distributions, Your Stat Prof](https://gregorkb.github.io/statmeth/part_random_variables/bernoulli_binomial.html)
4. [Bernoulli Distribution, ScienceDirect topic page](https://www.sciencedirect.com/science/article/pii/B9780080448947017218)
5. [11.1: Introduction to Bernoulli Trials, Statistics LibreTexts (Siegrist)](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/11%3A_Bernoulli_Trials/11.01%3A_Introduction_to_Bernoulli_Trials)
6. [7 Standard discrete distributions, The Theory of Statistical Distributions (bookdown)](https://bookdown.org/pkaldunn/DistTheory/DiscreteDistributions.html)
7. [The Exponential Family: Basics, course chapter by Michael I. Jordan, UC Berkeley](https://people.eecs.berkeley.edu/~jordan/courses/260-spring10/other-readings/chapter8.pdf)
8. [Chapter 7: Bayesian Estimation, Purdue STAT 611](https://www.stat.purdue.edu/~fmliang/STAT611/st611ch7Bayes.pdf)
9. [Bernoulli's Law of Large Numbers, ASTIN Bulletin (Cambridge University Press)](https://www.cambridge.org/core/journals/astin-bulletin-journal-of-the-iaa/article/bernoullis-law-of-large-numbers/103E1519C96A3C1787DFEB777A30DFB2)
10. [Bernoulli and Binomial Random Variables, Stanford CS109 lecture notes](https://web.stanford.edu/class/archive/cs/cs109/cs109.1204/lectureNotes/LN07_bernoulli_binomial.pdf)
11. [Bernoulli distribution: Important properties and comparison of estimation methods (Exa library)](https://doi.org/10.66147/lapm.20253129)
12. [Quantification of Model Uncertainty Based on Variance and Entropy of Bernoulli Distribution, Mathematics (MDPI, 2022)](https://www.mdpi.com/2227-7390/10/21/3980)
13. [Bernoulli trials, Encyclopedia of Mathematics](https://encyclopediaofmath.org/wiki/Bernoulli_trials)
14. [27.2 Distributions, Dive into Deep Learning](https://d2l.smola.org/chapter_mdl-probability-statistics/mdl-distributions.html)
15. [The Exponential Family, course notes by David Blei, Columbia University](https://www.cs.columbia.edu/~blei/fogm/2016F/doc/exponential_families.pdf)
16. [Bernoullis and Binomials, machine learning course notes by Kevin Murphy](https://www.ccs.neu.edu/home/vip/teach/MLcourse/3_generative_models/lecture_notes/Murphy_bernoulli_multinom.pdf)
17. [Estimation in the Bernoulli Model, Virtual Labs in Probability (randomservices.org)](https://www.randomservices.org/random/interval/Bernoulli.html)
18. [scipy.stats.bernoulli, SciPy v1.18.0 Manual](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.bernoulli.html)
19. [torch.bernoulli, PyTorch documentation](https://docs.pytorch.org/docs/2.3/generated/torch.bernoulli.html)
20. [tensorflow_probability/python/distributions/bernoulli.py, GitHub](https://github.com/tensorflow/probability/blob/master/tensorflow_probability/python/distributions/bernoulli.py)
21. [The continuous Bernoulli: fixing a pervasive error in variational autoencoders, NeurIPS 2019](https://proceedings.neurips.cc/paper/2019/file/f82798ec8909d23e55679ee26bb26437-Paper.pdf)
22. [Source code for torch.distributions.continuous_bernoulli, PyTorch](https://docs.pytorch.org/docs/2.3/_modules/torch/distributions/continuous_bernoulli.html)
23. [The difficult birth of stochastics: Jacob Bernoulli's Ars Conjectandi (1713), Historia Mathematica (2014)](https://bez.unibas.ch/fileadmin/user_upload/bez/The-difficult-birth-of-stochastics-Jacob-Bernoulli-s-Ars-Conjectandi-1713-_2014_Historia-Mathematica.pdf)
24. [Translations from James Bernoulli (Bing Sung), probabilityandfinance.com](https://www.probabilityandfinance.com/pulskamp/JakobBernoulli/ars_sung.pdf)
25. [Bernoulli, Jakob, Encyclopedia of Mathematics](https://encyclopediaofmath.org/wiki/Bernoulli,_Jakob)
26. [Tercentenary of Ars Conjectandi (1713), International Statistical Review](https://onlinelibrary.wiley.com/doi/10.1111/insr.12050)
27. [mas.ncl.ac.uk](https://www.mas.ncl.ac.uk/ask/numeracy-maths-statistics/statistics/distributions/bernoulli-distribution.html)

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

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Probability theory › Probability distributions › Distribution families and classification › Discrete distribution families

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/bernoulli-distribution

English original: https://www.edgepedia.org/bernoulli-distribution
