# 伯努利模型

伯努利模型是用于二值数据的一种统计模型：每一次观测取两种结果之一，习惯上称为成功或失败，成功概率固定。其概率质量函数为 \( f(y) = \pi^{y} \cdot (1-\pi)^{1-y} \)，其中 \( y \in \{0,1\} \)；唯一的参数 \( \pi \) 既是成功概率，也是该分布的均值。<sup>[1](https://stats.libretexts.org/Courses/Knox_College/Linear_Models_and_Rurita_Kralovstvi/15%3A_Binary_Dependent_Variables/15.03%3A_The_Mathematics)</sup> 由于一个参数就完全决定了均值（\( \pi \)）与方差（\( \pi \cdot (1-\pi) \)），该模型是二分类数据的基本构件，也是建立在它之上的二项模型、逻辑回归模型与朴素贝叶斯模型的基本构件。<sup>[2](https://www.mdpi.com/2571-905X/7/1/16)</sup> 一次成功概率为 \( \pi \) 的伯努利试验，等价于一个 Binomial\([1, \pi]\) 变量。<sup>[3](http://www.gllamm.org/JEBSredundant_07.pdf)</sup>

| 关键事实 | 取值或表述 |
|---|---|
| 概率质量函数 | \( f(y) = \pi^{y} \cdot (1-\pi)^{1-y} \)，\( y \in \{0,1\} \)<sup>[1](https://stats.libretexts.org/Courses/Knox_College/Linear_Models_and_Rurita_Kralovstvi/15%3A_Binary_Dependent_Variables/15.03%3A_The_Mathematics)</sup> |
| 均值与方差 | \( E[X] = \pi \)，\( \mathrm{Var}[X] = \pi \cdot (1-\pi) \)<sup>[4](https://www.ccs.neu.edu/home/vip/teach/MLcourse/3_generative_models/lecture_notes/Murphy_bernoulli_multinom.pdf)</sup> |
| 最大似然估计量 | \( \hat{\pi} = Y/n \)，即样本比例，且 \( V(\hat{\pi}) = \pi \cdot (1-\pi)/n \)<sup>[5](https://online.stat.psu.edu/stat504/Lesson02)</sup> |
| 与二项分布的关系 | 一次伯努利试验即 Binomial\([1, \pi]\)；\( n \) 次独立试验给出 Binomial\((n, \pi)\)<sup>[3](http://www.gllamm.org/JEBSredundant_07.pdf)</sup> |
| 历史渊源 | 伯努利试验的大数定律出现在《推测术》中<sup>[6](https://arxiv.org/pdf/1309.6488)</sup> |
| 朴素贝叶斯事件模型 | 在五个文本语料库上，多项朴素贝叶斯相对多元伯努利模型平均降低 27% 的误差<sup>[7](http://www.kamalnigam.com/papers/multinomial-aaaiws98.pdf)</sup> |
| 区间估计的告诫 | 沃尔德区间的覆盖率往往偏小；威尔逊得分区间即使在样本极小的情况下也接近名义水平<sup>[8](https://math.unm.edu/%7Ejames/Agresti1998.pdf)</sup> |

## 工作原理

对于参数为 \( \pi \) 的独立伯努利观测 \( y_1, \ldots, y_n \)，似然为 \( L(\pi) = \prod_{i} f(y_i; \pi) \)，对数似然为 \( \ell(\pi) = \left(\sum_i y_i\right) \log \pi + \left(n - \sum_i y_i\right) \log(1-\pi) \)。似然只通过 \( T = \sum_i y_i \)（即成功次数）依赖数据，因此 \( T \) 是充分统计量。<sup>[9](https://projecteuclid.org/ebook/Download?isFullBook=False&urlid=10.1214%2Fcbms%2F1462106040)</sup> 最大化对数似然得到 \( \hat{\pi} = Y/n \)，即样本比例，且 \( E(\hat{\pi}) = \pi \)、\( V(\hat{\pi}) = \pi \cdot (1-\pi)/n \)。<sup>[4](https://www.ccs.neu.edu/home/vip/teach/MLcourse/3_generative_models/lecture_notes/Murphy_bernoulli_multinom.pdf)</sup><sup> • </sup><sup>[5](https://online.stat.psu.edu/stat504/Lesson02)</sup>

方差 \( \pi \cdot (1-\pi) \) 是均值的二次函数，在 \( \pi = 0.5 \) 处最大。<sup>[1](https://stats.libretexts.org/Courses/Knox_College/Linear_Models_and_Rurita_Kralovstvi/15%3A_Binary_Dependent_Variables/15.03%3A_The_Mathematics)</sup> 推断所利用的正是这种均值与方差的固定联系：由中心极限定理，标准化后的估计量近似为 \( \pi \) 的标准正态枢轴量。<sup>[10](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_%28Siegrist%29/08%3A_Set_Estimation/8.03%3A_Estimation_in_the_Bernoulli_Model)</sup> 当 \( n \) 次 \( \pi \) 恒定的独立试验被合并分组时，成功计数服从 Binomial\((n, \pi)\)；伯努利模型正是这一框架中 \( n = 1 \) 的情形。<sup>[3](http://www.gllamm.org/JEBSredundant_07.pdf)</sup>

## 具体做法

检验 \( H_0: \pi = \pi_0 \) 的大样本检验有三种标准做法。沃尔德检验使用 \( Z_w = (\hat{\pi} - \pi_0)/\sqrt{\hat{\pi} \cdot (1-\hat{\pi})/n} \)，在 \( n \) 较大时近似标准正态；得分检验使用 \( Z_s = (\hat{\pi} - \pi_0)/\sqrt{\pi_0 \cdot (1-\pi_0)/n} \)，即在方差中代入原假设下的取值；似然比统计量为 \( G^2 = 2\left[\ell(\hat{\pi}) - \ell(\pi_0)\right] = 2\left(y\log\frac{\hat{\pi}}{\pi_0} + (n-y)\log\frac{1-\hat{\pi}}{1-\pi_0}\right) \)。<sup>[5](https://online.stat.psu.edu/stat504/Lesson02)</sup>

沃尔德区间 \( \hat{\pi} \pm z_{\alpha/2} \cdot \sqrt{\hat{\pi} \cdot (1-\hat{\pi})/n} \)（95% 覆盖率下 \( z_{.025} = 1.96 \)）在 \( \pi \) 接近 0 或 1 时表现很差，即使 \( n \) 很大也是如此；而当 \( n \) 中等时，即便 \( \pi \) 接近 0.5，覆盖率也可能偏低。<sup>[5](https://online.stat.psu.edu/stat504/Lesson02)</sup><sup> • </sup><sup>[11](https://alanagresti.com/articles/ci_proportion.pdf)</sup> 用原假设下的标准误反演得分检验，便得到威尔逊区间，其覆盖率即使在样本量极小时也接近名义水平；其中心为 \( (\hat{\pi} + z^2/2n)/(1 + z^2/n) \)。<sup>[8](https://math.unm.edu/%7Ejames/Agresti1998.pdf)</sup><sup> • </sup><sup>[5](https://online.stat.psu.edu/stat504/Lesson02)</sup> 贝塔分布是伯努利似然的共轭先验；\( \alpha_1 = \alpha_0 = 1 \) 为均匀（拉普拉斯）先验，\( \alpha_1 = \alpha_0 = 1/2 \) 为杰弗里斯先验，后者给出等尾的杰弗里斯区间。<sup>[4](https://www.ccs.neu.edu/home/vip/teach/MLcourse/3_generative_models/lecture_notes/Murphy_bernoulli_multinom.pdf)</sup><sup> • </sup><sup>[12](http://www-stat.wharton.upenn.edu/%7Etcai/paper/Binomial-StatSci.pdf)</sup> 在研究设计阶段，可以为置信水平 \( 1-\alpha \) 与误差限 \( d \) 选取一个保守的样本量。<sup>[10](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_%28Siegrist%29/08%3A_Set_Estimation/8.03%3A_Estimation_in_the_Bernoulli_Model)</sup>

## 源流

用于朴素贝叶斯文本分类的多元伯努利事件模型，以及它与多项事件模型的比较，通常归功于安德鲁·麦卡勒姆（Andrew McCallum）与卡迈勒·尼加姆（Kamal Nigam）1998 年的工作。<sup>[7](http://www.kamalnigam.com/papers/multinomial-aaaiws98.pdf)</sup> 该模型的历史根源在《推测术》（1713）：在伯努利试验的独立重复中，成功的相对频率随试验次数无限增加而依概率收敛于未知的成功概率。<sup>[13](https://www.sciencedirect.com/science/article/pii/S0315086014000482)</sup><sup> • </sup><sup>[6](https://arxiv.org/pdf/1309.6488)</sup> 对 \( \pi \) 的贝叶斯估计则在二项成功概率上取均匀先验，用贝叶斯定理解决雅各布·伯努利（Jacob Bernoulli）的反演问题，以后验均值作为预测概率，即今天所说的贝叶斯估计量。<sup>[6](https://arxiv.org/pdf/1309.6488)</sup>

## 变体

在文本分类中，多元伯努利模型把一篇文档表示为词表上的二值向量，每个词项是否出现由一个伯努利分布支配，其类别条件参数为 \( \theta_{tk|ci} = P(t_k|c_i; \theta) \)。<sup>[7](http://www.kamalnigam.com/papers/multinomial-aaaiws98.pdf)</sup><sup> • </sup><sup>[14](https://ceur-ws.org/Vol-835/paper5.pdf)</sup> 最大似然估计为 \( \hat{\theta}_{\mathrm{ML}} = \tau_{k,i}/m_i \)，即类别 \( c_i \) 的文档中含有词项 \( t_k \) 的比例；共轭贝塔先验给出平滑估计 \( (\tau_{k,i}+\alpha)/(m_i+\alpha+\beta) \)，其中 \( \alpha = 1, \beta = 1 \) 称为拉普拉斯平滑；杰利内克-默瑟平滑则把最大似然估计与一个语料库语言模型做插值。<sup>[14](https://ceur-ws.org/Vol-835/paper5.pdf)</sup>

在回归情形中，建立在单变量伯努利分布之上的广义线性模型就是逻辑回归；把它推广到二值响应向量，便得到多元伯努利逻辑模型，该模型支持点估计、假设检验、置信区间与 LASSO 变量选择。<sup>[15](https://pages.cs.wisc.edu/~sding/paper/mvb.pdf)</sup>

## 应用

伯努利模型把 \( P(t|c) \) 估计为含有该词项的文档比例，只利用出现与否的二值信息，而忽略出现次数。<sup>[16](https://nlp.stanford.edu/IR-book/html/htmledition/the-bernoulli-model-1.html)</sup> 麦卡勒姆与尼加姆发现，多元伯努利模型在词表规模较小时表现良好，但无论词表规模多大，多项模型平均都能降低 27% 的误差。<sup>[7](http://www.kamalnigam.com/papers/multinomial-aaaiws98.pdf)</sup> scikit-learn 直接实现了这一区分：BernoulliNB 面向二值／布尔特征，而 MultinomialNB 处理出现次数。<sup>[17](https://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.BernoulliNB)</sup>

## 局限与替代方案

该模型的核心限制在于固定的均值-方差关系。对单次二分类观测而言，均值-方差关系始终是固定的，因此在伯努利层面上不存在过度离散或离散不足的余地；过度离散出现在分组数据中，此时成功计数的方差超过二项方差。<sup>[3](http://www.gllamm.org/JEBSredundant_07.pdf)</sup> 在这一点上文献意见不一。主流观点认为，伯努利变异的过量或不足无从谈起，过度离散需要不止一次试验。<sup>[2](https://www.mdpi.com/2571-905X/7/1/16)</sup> 「隐含过度离散」一词用于二值 logit 模型：这类模型一旦转换为分组格式，便被证明是过度离散的；同时也有人指出，仅凭未分组数据本身，无法一眼看出二值模型存在额外离散。<sup>[18](http://www.highstat.com/Books/BGS/GLMGLMM/pdfs/HILBE-Can_binary_logistic_models_be_overdispersed2Jul2013.pdf)</sup>

对于分组数据的过度离散，标准的替代方案假定 \( \pi \sim \mathrm{Beta}(\alpha, \beta) \)，于是无条件地看，成功计数服从贝塔-二项分布。<sup>[19](https://pmc.ncbi.nlm.nih.gov/articles/PMC5736152/)</sup> 这一由贝叶斯导出的贝塔分布与二项分布的复合分布，作为刻画二项变异异常的工具，长期处于沉寂状态。<sup>[2](https://www.mdpi.com/2571-905X/7/1/16)</sup> 伯努利模型是唯一显式建模词项「不出现」的朴素贝叶斯事件模型；因此它在长文档上通常错误很多。<sup>[16](https://nlp.stanford.edu/IR-book/html/htmledition/the-bernoulli-model-1.html)</sup> 还有两点告诫：对伯努利变量而言，独立与不相关是等价的，因此零相关不能被当作任何弱于完全独立的证据；<sup>[15](https://pages.cs.wisc.edu/~sding/paper/mvb.pdf)</sup> 而把伯努利似然用于非二值数据是一种有文献记载的失败模式——用支撑集仅为 \( \{0,1\} \) 的伯努利似然去建模取值于 \( [0,1] \) 的像素数据，是变分自编码器中一种普遍存在的错误，后果严重。<sup>[20](https://proceedings.neurips.cc/paper/2019/file/f82798ec8909d23e55679ee26bb26437-Paper.pdf)</sup>

## References

1. [15.3: The Mathematics – Statistics LibreTexts (Knox College)](https://stats.libretexts.org/Courses/Knox_College/Linear_Models_and_Rurita_Kralovstvi/15%3A_Binary_Dependent_Variables/15.03%3A_The_Mathematics)
2. [Comments on the Bernoulli Distribution and Hilbe's Implicit Extra-Dispersion](https://www.mdpi.com/2571-905X/7/1/16)
3. [Redundant Overdispersion Parameters in Multilevel Models for Categorical Responses](http://www.gllamm.org/JEBSredundant_07.pdf)
4. [Bernoullis and Binomials (Kevin Murphy, Machine Learning course notes)](https://www.ccs.neu.edu/home/vip/teach/MLcourse/3_generative_models/lecture_notes/Murphy_bernoulli_multinom.pdf)
5. [2 Binomial and Multinomial Inference – STAT 504 | Analysis of Discrete Data (Penn State)](https://online.stat.psu.edu/stat504/Lesson02)
6. [A Tricentenary history of the Law of Large Numbers](https://arxiv.org/pdf/1309.6488)
7. [A Comparison of Event Models for Naive Bayes Text Classification (McCallum & Nigam, AAAI-98 Workshop)](http://www.kamalnigam.com/papers/multinomial-aaaiws98.pdf)
8. [Approximate is better than 'exact' for interval estimation of binomial proportions (Agresti & Coull, The American Statistician, 1998)](https://math.unm.edu/%7Ejames/Agresti1998.pdf)
9. [CBMS monograph (Project Euclid, DOI 10.1214/cbms/1462106040)](https://projecteuclid.org/ebook/Download?isFullBook=False&urlid=10.1214%2Fcbms%2F1462106040)
10. [8.03: Estimation in the Bernoulli Model (stats.libretexts.org)](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_%28Siegrist%29/08%3A_Set_Estimation/8.03%3A_Estimation_in_the_Bernoulli_Model)
11. [On Sample Size Guidelines for Teaching Inference about the Binomial Parameter in Introductory Statistics (Agresti & Coull)](https://alanagresti.com/articles/ci_proportion.pdf)
12. [Interval Estimation for a Binomial Proportion (Brown, Cai, DasGupta, Statistical Science)](http://www-stat.wharton.upenn.edu/%7Etcai/paper/Binomial-StatSci.pdf)
13. [The difficult birth of stochastics: Jacob Bernoulli's Ars Conjectandi (1713)](https://www.sciencedirect.com/science/article/pii/S0315086014000482)
14. [How well do we know Bernoulli? (smoothing for the multivariate Bernoulli NB classifier)](https://ceur-ws.org/Vol-835/paper5.pdf)
15. [Multivariate Bernoulli distribution (Dai, Ding & Wahba)](https://pages.cs.wisc.edu/~sding/paper/mvb.pdf)
16. [The Bernoulli model (Manning, Raghavan & Schütze, Introduction to Information Retrieval)](https://nlp.stanford.edu/IR-book/html/htmledition/the-bernoulli-model-1.html)
17. [BernoulliNB, scikit-learn 1.9.0 documentation](https://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.BernoulliNB)
18. [Can binary logistic models be overdispersed? (Hilbe technical note)](http://www.highstat.com/Books/BGS/GLMGLMM/pdfs/HILBE-Can_binary_logistic_models_be_overdispersed2Jul2013.pdf)
19. [The Validation of a Beta-Binomial Model for Overdispersed Binomial Data](https://pmc.ncbi.nlm.nih.gov/articles/PMC5736152/)
20. [The continuous Bernoulli: fixing a pervasive error in variational autoencoders](https://proceedings.neurips.cc/paper/2019/file/f82798ec8909d23e55679ee26bb26437-Paper.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/bernoulli-model

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