Skip to main content
`Ctrl`+`K`

# histogram

astropy.stats.histogram(a, bins=10, range=None, weights=None, **kwargs)

  Enhanced histogram function, providing adaptive binnings.

  This is a histogram function that enables the use of more sophisticated algorithms for determining bins. Aside from the `bins` argument allowing a string specified how bins are computed, the parameters are the same as `numpy.histogram`.

  Parameters:
    a numpy:array_like

      array of data to be histogrammed

    bins `python:int`, `python:list`, or `python:str`, optional

      If bins is a string, then it must be one of:

      - ‘blocks’ : use bayesian blocks for dynamic bin widths

      - ‘knuth’ : use Knuth’s rule to determine bins

      - ‘scott’ : use Scott’s rule to determine bins

      - ‘freedman’ : use the Freedman-Diaconis rule to determine bins

    range `python:tuple` or `python:None`, optional

      the minimum and maximum range for the histogram. If not specified, it will be (x.min(), x.max())

    weights numpy:array_like, optional

      An array the same shape as `a`. If given, the histogram accumulates the value of the weight corresponding to `a` instead of returning the count of values. This argument does not affect determination of bin edges.

    **kwargs `python:dict`, optional

      Extra arguments are described in `numpy.histogram`.

  Returns:
    hist `array`

      The values of the histogram. See `density` and `weights` for a description of the possible semantics.

    bin_edges `array` of `dtype` `python:float`

      Return the bin edges `(length(hist)+1)`.

  See also

  `numpy.histogram`