freedman_bin_width¶

astropy.stats.
freedman_bin_width
(data, return_bins=False)[source] [edit on github]¶ Return the optimal histogram bin width using the FreedmanDiaconis rule
The FreedmanDiaconis rule is a normal reference rule like Scott’s rule, but uses rankbased statistics for results which are more robust to deviations from a normal distribution.
Parameters: data : arraylike, ndim=1
observed (onedimensional) data
return_bins : bool (optional)
if True, then return the bin edges
Returns: width : float
optimal bin width using the FreedmanDiaconis rule
bins : ndarray
bin edges: returned if
return_bins
is TrueSee also
knuth_bin_width
,scott_bin_width
,bayesian_blocks
,histogram
Notes
The optimal bin width is
\[\Delta_b = \frac{2(q_{75}  q_{25})}{n^{1/3}}\]where \(q_{N}\) is the \(N\) percent quartile of the data, and \(n\) is the number of data points [R51].
References
[R51] (1, 2) D. Freedman & P. Diaconis (1981) “On the histogram as a density estimator: L2 theory”. Probability Theory and Related Fields 57 (4): 453476