# 斯特吉斯规则

**斯特吉斯规则**（Sturges's rule）是一个仅凭样本量来选择直方图或频率分布中类别（箱）数的公式：
\[ k = 1 + \log_{2}(n) \]
其中 \( n \) 是观测值的数量。沃什本学院的赫伯特·A·斯特吉斯（Herbert A. Sturges）于1926年在《美国统计协会杂志》上发表了这一公式，它是统计文献中第一个箱数规则。<sup>[1](https://www.stat.rice.edu/~scottdw/stat550/DEMOS/09-14-hist/Sturges1926.pdf)</sup><sup> • </sup><sup>[2](https://onlinelibrary.wiley.com/doi/full/10.1002/wics.35)</sup> 它至今仍是R语言`hist()`函数的默认箱数规则，也是NumPy中命名的估计器之一。<sup>[3](https://search.r-project.org/R/refmans/graphics/help/hist.html)</sup><sup> • </sup><sup>[4](https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.histogram_bin_edges.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 公式 | \( k = 1 + \log_{2}(n) \)，等价于 \( k = 1 + 3.322 \log_{10}(n) \)<sup>[1](https://www.stat.rice.edu/~scottdw/stat550/DEMOS/09-14-hist/Sturges1926.pdf)</sup><sup> • </sup><sup>[4](https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.histogram_bin_edges.html)</sup> |
| 起源 | 赫伯特·A·斯特吉斯，《组距的选择》，《美国统计协会杂志》21 (1926): 65–66<sup>[1](https://www.stat.rice.edu/~scottdw/stat550/DEMOS/09-14-hist/Sturges1926.pdf)</sup><sup> • </sup><sup>[2](https://onlinelibrary.wiley.com/doi/full/10.1002/wics.35)</sup> |
| 所用信息 | 仅使用样本量；从不考虑数据的离散程度或形状<sup>[4](https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.histogram_bin_edges.html)</sup> |
| 假设 | 数据大致正态；仅对高斯数据最优<sup>[4](https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.histogram_bin_edges.html)</sup> |
| 已知缺陷 | 对于大样本或非正态数据集会低估箱数，使直方图过度平滑<sup>[4](https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.histogram_bin_edges.html)</sup><sup> • </sup><sup>[5](https://www.stat.rice.edu/~scottdw/stat550/Lectures/Chapter3.pdf)</sup> |
| 软件现状 | R的`hist()`中的默认值；NumPy中的`sturges`选项；NumPy的`auto`取斯特吉斯与弗里德曼-迪亚科尼斯估计的较大值<sup>[3](https://search.r-project.org/R/refmans/graphics/help/hist.html)</sup><sup> • </sup><sup>[4](https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.histogram_bin_edges.html)</sup> |

## 起源与原理

斯特吉斯1926年的短文《组距的选择》讨论了如何将具有\( N \)个数据项、极差为\( R \)的统计序列划分为若干类别。他给出的组距为
\[ C = \frac{R}{1 + 3.322 \log N} \]
这等价于箱数为\( 1 + \log_{2}(n) \)。<sup>[1](https://www.stat.rice.edu/~scottdw/stat550/DEMOS/09-14-hist/Sturges1926.pdf)</sup>

该推导基于一个二项式论证。斯特吉斯提出，随着箱数\( k \)的增加，二项式系数\( \binom{k-1}{i} \)可以作为正态数据的理想化箱频数，因为二项分布在\( k \)增大时趋近于正态分布。例如，16个数据项可自然地分为5个类别，频数分别为1、4、6、4、1；而64个数据项（2的六次方）的序列则分为7个类别。<sup>[1](https://www.stat.rice.edu/~scottdw/stat550/DEMOS/09-14-hist/Sturges1926.pdf)</sup><sup> • </sup><sup>[6](https://www.stat.rice.edu/~scottdw/ss.nh.pdf)</sup> 对给定\( k \)的二项式系数求和得到\( 2^{k-1} \)，因此\( k = 1 + \log_{2}(n) \)。

斯特吉斯还就该公式的应用提供了实用指导。他指出，最方便的组距是1、2、5、10、20等，并建议选择接近理论值的方便组距：如果公式给出9，则用10；但如果指示7或8，则用5。对于涉及两个序列的计算，例如事先已知近似值\( r \)的相关系数，他推导了一个变体：
\[ C = \frac{R}{1 + (1.661 + 1.661\,r) \log N} \]
对于许多\( r \approx 0.50 \)的生物学相关性，该式在\( \log N \)上的系数约为2.5。<sup>[1](https://www.stat.rice.edu/~scottdw/stat550/DEMOS/09-14-hist/Sturges1926.pdf)</sup>

## 规则的表现

由于该规则仅依赖于\( n \)，箱数呈对数增长：100个观测值约需8个箱，1,000个约需11个。<sup>[7](https://histogramhub.com/blog/sturges-scott-freedman-diaconis-bin-rules)</sup> 莱斯大学荣休统计学诺亚·哈丁讲席教授戴维·W·斯科特（David W. Scott）撰写了该规则的标准综述，他将所得箱数与基于宽度的替代方法并列列表：<sup>[2](https://onlinelibrary.wiley.com/doi/full/10.1002/wics.35)</sup><sup> • </sup><sup>[8](https://www.stat.rice.edu/~scottdw/)</sup>

| \( n \) | 斯特吉斯 | 斯科特 | 弗里德曼-迪亚科尼斯 |
|---:|---:|---:|---:|
| 50 | 5.6 | 6.3 | 8.5 |
| 100 | 7.6 | 8.0 | 10.8 |
| 1,000 | 11.0 | 17.2 | 23.2 |
| 10,000 | 14.3 | 37.0 | 49.9 |
| 100,000 | 17.6 | 79.8 | 107.6 |

差距随样本量增大而扩大，因为对数增长过慢。斯科特的评价是，斯特吉斯规则在大\( n \)下过于保守，会使直方图过度平滑，箱过宽而丢失信息。<sup>[5](https://www.stat.rice.edu/~scottdw/stat550/Lectures/Chapter3.pdf)</sup> 在Beta(5, 5)密度上，他的数据表明斯特吉斯隐含的箱宽在\( n = 128 \)时偏大13.7%，在\( n = 1{,}024 \)时偏大65.3%，在\( n = 1{,}048{,}576 \)时偏大772.9%，积分误差分别比最优值大1.7%、31.4%和2,447.5%。<sup>[5](https://www.stat.rice.edu/~scottdw/stat550/Lectures/Chapter3.pdf)</sup>

该规则除了计数之外完全忽略数据。偏斜或含离群值的样本与相同大小的对称样本得到相同的箱数，因为离散程度从不进入公式。<sup>[4](https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.histogram_bin_edges.html)</sup><sup> • </sup><sup>[7](https://histogramhub.com/blog/sturges-scott-freedman-diaconis-bin-rules)</sup>

## 与其他箱数规则的关系

后来的规则采取了不同的路径：它们选择箱宽\( h \)，然后通过将数据范围除以\( h \)得到箱数。两种正态参考规则主导了实践。<sup>[5](https://www.stat.rice.edu/~scottdw/stat550/Lectures/Chapter3.pdf)</sup>

**斯科特规则**出自斯科特1979年发表于《生物计量学》的论文《论最优直方图与基于数据的直方图》，它最小化直方图的渐近积分均方误差，并在假设数据服从正态分布的条件下，给出
\[ h = 3.49 \, \hat{\sigma} \, n^{-1/3} \]
其中\( \hat{\sigma} \)为样本标准差。\( n^{-1/3} \)的缩放对于直方图箱宽而言通常是渐近最优的。<sup>[5](https://www.stat.rice.edu/~scottdw/stat550/Lectures/Chapter3.pdf)</sup><sup> • </sup><sup>[4](https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.histogram_bin_edges.html)</sup>

**弗里德曼-迪亚科尼斯规则**出自戴维·弗里德曼（David Freedman）和佩尔西·迪亚科尼斯（Persi Diaconis）1981年的论文《论作为密度估计量的直方图：L²理论》，它用四分位距代替标准差：
\[ h = 2 \cdot \mathrm{IQR} \cdot n^{-1/3} \]
四分位距即第25百分位与第75百分位之间的距离，对离群值稳健，因此少数极端值几乎不会改变箱宽。对于正态数据，弗里德曼-迪亚科尼斯宽度比斯科特窄约23%。<sup>[5](https://www.stat.rice.edu/~scottdw/stat550/Lectures/Chapter3.pdf)</sup>

与斯特吉斯的对比是结构性的。像斯特吉斯这样基于计数的规则无法对离散程度作出响应，因此离群值不会改变任何东西；基于宽度的规则则适应数据的分散程度，这就是为什么斯科特规则适合大致钟形的数据，而弗里德曼-迪亚科尼斯适合偏斜或离群值较多的数据。<sup>[7](https://histogramhub.com/blog/sturges-scott-freedman-diaconis-bin-rules)</sup> NumPy的文档将`sturges`描述为仅对高斯数据最优，且对大型非高斯数据集会低估箱数，其`auto`默认值取斯特吉斯和弗里德曼-迪亚科尼斯估计的最大值，对小数据集选择斯特吉斯，并在\( n \approx 1000 \)附近切换到弗里德曼-迪亚科尼斯。<sup>[4](https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.histogram_bin_edges.html)</sup>

多恩公式是斯特吉斯的直接修改：
\[ n_h = 1 + \log_{2}(n) + \log_{2}\!\left(1 + \frac{|g_1|}{\sigma_{g_1}}\right) \]
其中\( g_1 \)为样本偏度，它通过考虑偏度对非正态数据集产生更好的估计。<sup>[4](https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.histogram_bin_edges.html)</sup>

## 在软件与实践中的使用

斯特吉斯规则是R的`hist()`函数`breaks`参数的默认值，`"Scott"`和`"FD"`可通过`nclass.scott`和`nclass.FD`作为命名替代方案使用。<sup>[3](https://search.r-project.org/R/refmans/graphics/help/hist.html)</sup> NumPy将其作为`histogram_bin_edges`的`"sturges"`选项提供。<sup>[4](https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.histogram_bin_edges.html)</sup>

在实践中，该规则是起点而非定论。一个能揭示某种特征的箱数可能会掩盖另一种特征：在15个箱时清晰分离的两个峰在8个箱时可能合并为一个，因此选择8的规则会暗示数据是单峰的，而实际上数据是双峰的。建议实践者绘制直方图，并检查当箱数上下微调时可见形状是否保持。<sup>[7](https://histogramhub.com/blog/sturges-scott-freedman-diaconis-bin-rules)</sup> 一项2021年的感知研究将斯特吉斯、斯科特、赖斯和弗里德曼-迪亚科尼斯与人类观察者进行比较，发现这些公式大多高估了使分布对人眼可见所需的箱数。<sup>[9](https://arxiv.org/abs/2109.06612)</sup>

## References

1. [Herbert A. Sturges (1926). "The Choice of a Class Interval." Journal of the American Statistical Association 21: 65–66.](https://www.stat.rice.edu/~scottdw/stat550/DEMOS/09-14-hist/Sturges1926.pdf)
2. [David W. Scott (2009). "Sturges' rule." WIREs Computational Statistics 1: 303–306.](https://onlinelibrary.wiley.com/doi/full/10.1002/wics.35)
3. [R Documentation: hist {graphics}](https://search.r-project.org/R/refmans/graphics/help/hist.html)
4. [NumPy v1.15 Manual: numpy.histogram_bin_edges](https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.histogram_bin_edges.html)
5. [David W. Scott. Nonparametric Function Estimation, Chapter 3 (Stat 550A course notes, Rice University).](https://www.stat.rice.edu/~scottdw/stat550/Lectures/Chapter3.pdf)
6. [David W. Scott. Lecture notes on Sturges' rule derivation (Rice University).](https://www.stat.rice.edu/~scottdw/ss.nh.pdf)
7. [Sturges, Scott, and Freedman-Diaconis: Which Bin Rule Should You Use? Histogram Hub](https://histogramhub.com/blog/sturges-scott-freedman-diaconis-bin-rules)
8. [David W. Scott's home page, Rice University](https://www.stat.rice.edu/~scottdw/)
9. [Histogram binning revisited with a focus on human perception (arXiv:2109.06612)](https://arxiv.org/abs/2109.06612)

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

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Statistical inference, estimation, sampling, and testing › Foundations of statistical inference › Statistical inference: overview

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/sturgess-rule

English original: https://www.edgepedia.org/sturgess-rule
