histogram(a, bins=10, range=None, normed=None, weights=None, density=None)

Compute the histogram of a set of data.

  • a (ndarray) – Input data. The histogram is computed over the flattened array.

  • bins (int or ndarray) – If bins is an int, it defines the number of equal-width bins in the given range (10, by default). If bins is a sequence, it defines a monotonically increasing array of bin edges, including the rightmost edge, allowing for non-uniform bin widths. .. versionadded:: 1.11.0 If bins is a string, it defines the method used to calculate the optimal bin width, as defined by histogram_bin_edges.

  • range ((float, float)) – The lower and upper range of the bins. Required when bins is an integer. Values outside the range are ignored. The first element of the range must be less than or equal to the second.

  • normed (bool, optional) – Not supported yet, coming soon.

  • weights (array_like, optional) – Not supported yet, coming soon.

  • density (bool, optional) – Not supported yet, coming soon.


>>> np.histogram(np.arange(4), bins=np.arange(5))
[array([1, 1, 1, 1], dtype=int64), array([0., 1., 2., 3., 4.])]