spacepy.toolbox.binHisto — SpacePy v0.1.5 Manual

### Navigation

- index
- modules |
- modules |
- next |
- previous |
- homepage|
- search|
- documentation »
- toolbox - Toolbox of various functions and generic utilities »

# spacepy.toolbox.binHisto

`spacepy.toolbox.` `binHisto`(data, verbose=False)

  Calculates bin width and number of bins for histogram using Freedman-Diaconis rule, if rule fails, defaults to square-root method

  The Freedman-Diaconis method is detailed in:
    Freedman, D., and P. Diaconis (1981), On the histogram as a density estimator: L2 theory, Z. Wahrscheinlichkeitstheor. Verw. Geb., 57, 453–476
  and is also described by:
    Wilks, D. S. (2006), Statistical Methods in the Atmospheric Sciences, 2nd ed.

  Parameters: | data : array_like list/array of data values verbose : boolean (optional) print out some more information
  Returns: | out : tuple calculated width of bins using F-D rule, number of bins (nearest integer) to use for histogram

  See also

  `matplotlib.pyplot.hist`

  Examples

      >>> import numpy, spacepy
      >>> import matplotlib.pyplot as plt
      >>> numpy.random.seed(8675301)
      >>> data = numpy.random.randn(1000)
      >>> binw, nbins = spacepy.toolbox.binHisto(data)
      >>> print(nbins)
      19.0
      >>> p = plt.hist(data, bins=nbins, histtype='step', normed=True)

### Navigation

- index
- modules |
- modules |
- next |
- previous |
- homepage|
- search|
- documentation »
- toolbox - Toolbox of various functions and generic utilities »