astro py:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- Astropy v5.2.1 »
- Astrostatistics Tools (`astropy.stats`) »
- scott_bin_width

# scott_bin_width

astropy.stats.scott_bin_width(data, return_bins=False)

  Return the optimal histogram bin width using Scott’s rule

  Scott’s rule is a normal reference rule: it minimizes the integrated mean squared error in the bin approximation under the assumption that the data is approximately Gaussian.

  Parameters:
    data numpy:array_like, ndim=1

      observed (one-dimensional) data

    return_bins bool, optional

      if True, then return the bin edges

  Returns:
    width `python:float`

      optimal bin width using Scott’s rule

    bins `ndarray`

      bin edges: returned if `return_bins` is True

  See also

  `knuth_bin_width`
  `freedman_bin_width`
  `bayesian_blocks`
  `histogram`

  Notes

  The optimal bin width is

  \[\Delta_b = \frac{3.5\sigma}{n^{1/3}}\]

  where \(\sigma\) is the standard deviation of the data, and \(n\) is the number of data points [1].

  References

  [1]

  Scott, David W. (1979). “On optimal and data-based histograms”. Biometricka 66 (3): 605-610