我必须使用直方图绘制一些数据。我的数据在 [0,1] 之间,没有大量集中在任何特定点上。
样本数与箱数(相同长度)之间的最佳比率是多少?
最佳答案
我一般使用样本数的平方根作为箱数。这是Wikipedia histogram article中有关适当数量的箱的讨论中列出的最简单的选择。 。摘自这篇文章
There is no "best" number of bins, and different bin sizes can reveal different features of the data. Some theoreticians have attempted to determine an optimal number of bins, but these methods generally make strong assumptions about the shape of the distribution.
如果您不想对数据的分布做出假设,那么使用样本数的平方根通常是一个不错的起点。
关于plot - 给定一些数据有多少个 bin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12055740/