Return the optimal histogram bin width using Knuth’s rule.
Knuth’s rule is a fixed-width, Bayesian approach to determining the optimal bin width of a histogram.
Parameters: | data : array-like, ndim=1
return_bins : bool (optional)
quiet : bool (optional)
|
---|---|
Returns: | dx : float
bins : ndarray
|
See also
freedman_bin_width, scott_bin_width, bayesian_blocks, histogram
Notes
The optimal number of bins is the value M which maximizes the function
F(M|x,I) = n\log(M) + \log\Gamma(\frac{M}{2}) - M\log\Gamma(\frac{1}{2}) - \log\Gamma(\frac{2n+M}{2}) + \sum_{k=1}^M \log\Gamma(n_k + \frac{1}{2})
where \Gamma is the Gamma function, n is the number of data points, n_k is the number of measurements in bin k [R18].
References
[R18] | (1, 2) Knuth, K.H. “Optimal Data-Based Binning for Histograms”. arXiv:0605197, 2006 |