plot - 给定一些数据有多少个 bin

标签 plot matplotlib histogram bin binning

我必须使用直方图绘制一些数据。我的数据在 [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/

相关文章:

python - 如何使用 datetime.time 在 Python 中绘图

python - PDF 后端目前不支持所选字体

plot - gnuplot:带有误差条的行堆积条形图

r - 叠加两个 ggplot facet_wrap 直方图

matlab - Matlab绘图时如何自动将不同的线型应用于数组

r - 如何在 r 中创建和弦图?

r - 如何使用 Shiny 在工具提示中显示情节

r - ggplot2:叠加密度图 R

python - 修复 x 轴 matplotlib 的比例

r - 在R中绘制频率密度直方图