numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersReturns
_hist_bin_auto(x, range)

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.

versionchanged

If there is limited variance the IQR can be 0, which results in the FD bin width being 0 too. This is not a valid bin width, so np.histogram_bin_edges chooses 1 bin instead, which may not be optimal. If the IQR is 0, it's unlikely any variance-based estimators will be of use, so we revert to the Sturges estimator, which only uses the size of the dataset in its calculation.

Parameters

x : array_like

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

Returns

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

Histogram bin estimator that uses the minimum width of the Freedman-Diaconis and Sturges estimators if the FD bin width is non-zero. If the bin width from the FD estimator is 0, the Sturges estimator is used.

See Also

_hist_bin_fd
_hist_bin_sturges

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/lib/histograms.py#229
type: <class 'function'>
Commit: