You are viewing an older version (2.4.3). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.4.3 / numpy / lib / _histograms_impl / _hist_bin_auto

function

numpy.lib._histograms_impl:_hist_bin_auto

source: /numpy/lib/_histograms_impl.py :230

Signature

def   _hist_bin_auto ( x range )

Summary

Histogram bin estimator that uses the minimum width of a relaxed Freedman-Diaconis and Sturges estimators if the FD bin width does not result in a large number of bins. The relaxed Freedman-Diaconis estimator limits the bin width to half the sqrt estimated to avoid small bins.

Extended Summary

The FD estimator is usually the most robust method, but its width estimate tends to be too large for small x and bad for data with limited variance. The Sturges estimator is quite good for small (<1000) datasets and is the default in the R language. This method gives good off-the-shelf behaviour.

Parameters

x : array_like

Input data that is to be histogrammed, trimmed to range. May not be empty.

range : Tuple with range for the histogram

Returns

h : An estimate of the optimal bin width for the given data.

See also

_hist_bin_fd
_hist_bin_sturges

Aliases

  • numpy.lib._histograms_impl._hist_bin_auto