# jax.numpy.histogram#

jax.numpy.histogram(a, bins=10, range=None, weights=None, density=None)[source]#

Compute the histogram of a dataset.

LAX-backend implementation of `numpy.histogram()`.

Original docstring below.

Parameters:
• a (array_like) â€“ Input data. The histogram is computed over the flattened array.

• bins (int or sequence of scalars or str, optional) â€“ 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.

• range ((float, float), optional) â€“ The lower and upper range of the bins. If not provided, range is simply `(a.min(), a.max())`. Values outside the range are ignored. The first element of the range must be less than or equal to the second. range affects the automatic bin computation as well. While bin width is computed to be optimal based on the actual data within range, the bin count will fill the entire range including portions containing no data.

• weights (array_like, optional) â€“ An array of weights, of the same shape as a. Each value in a only contributes its associated weight towards the bin count (instead of 1). If density is True, the weights are normalized, so that the integral of the density over the range remains 1. Please note that the `dtype` of weights will also become the `dtype` of the returned accumulator (hist), so it must be large enough to hold accumulated values as well.

• density (bool, optional) â€“ If `False`, the result will contain the number of samples in each bin. If `True`, the result is the value of the probability density function at the bin, normalized such that the integral over the range is 1. Note that the sum of the histogram values will not be equal to 1 unless bins of unity width are chosen; it is not a probability mass function.

Returns:

• hist (array) â€“ The values of the histogram. See density and weights for a description of the possible semantics. If weights are given, `hist.dtype` will be taken from weights.

• bin_edges (array of dtype float) â€“ Return the bin edges `(length(hist)+1)`.

Return type: