This documentation is for astroML version 0.2

This page


astroML Mailing List

GitHub Issue Tracker


Scipy 2012 (15 minute talk)

Scipy 2013 (20 minute talk)


If you use the software, please consider citing astroML. astroML.density_estimation.freedman_bin_width

astroML.density_estimation.freedman_bin_width(data, return_bins=False)

Return the optimal histogram bin width using the Freedman-Diaconis rule

Parameters :

data : array-like, ndim=1

observed (one-dimensional) data

return_bins : bool (optional)

if True, then return the bin edges

Returns :

width : float

optimal bin width using Scott’s rule

bins : ndarray

bin edges: returned if return_bins is True


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.