MCPcopy
hub / github.com/numpy/numpy / _hist_bin_fd

Function _hist_bin_fd

numpy/lib/_histograms_impl.py:200–227  ·  view source on GitHub ↗

The Freedman-Diaconis histogram bin estimator. The Freedman-Diaconis rule uses interquartile range (IQR) to estimate binwidth. It is considered a variation of the Scott rule with more robustness as the IQR is less affected by outliers than the standard deviation. However, the I

(x, range)

Source from the content-addressed store, hash-verified

198
199
200def _hist_bin_fd(x, range):
201 """
202 The Freedman-Diaconis histogram bin estimator.
203
204 The Freedman-Diaconis rule uses interquartile range (IQR) to
205 estimate binwidth. It is considered a variation of the Scott rule
206 with more robustness as the IQR is less affected by outliers than
207 the standard deviation. However, the IQR depends on fewer points
208 than the standard deviation, so it is less accurate, especially for
209 long tailed distributions.
210
211 If the IQR is 0, this function returns 0 for the bin width.
212 Binwidth is inversely proportional to the cube root of data size
213 (asymptotically optimal).
214
215 Parameters
216 ----------
217 x : array_like
218 Input data that is to be histogrammed, trimmed to range. May not
219 be empty.
220
221 Returns
222 -------
223 h : An estimate of the optimal bin width for the given data.
224 """
225 del range # unused
226 iqr = np.subtract(*np.percentile(x, [75, 25]))
227 return 2.0 * iqr * x.size ** (-1.0 / 3.0)
228
229
230def _hist_bin_auto(x, range):

Callers 1

_hist_bin_autoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…