numpy.histogramdd

numpy.histogramdd(sample, bins=10, range=None, normed=False, weights=None)

Compute the multidimensional histogram of some data.

Parameters:

sample : array_like

Data to histogram passed as a sequence of D arrays of length N, or as an (N,D) array.

bins : sequence or int, optional

The bin specification:

  • A sequence of arrays describing the bin edges along each dimension.
  • The number of bins for each dimension (nx, ny, ... =bins)
  • The number of bins for all dimensions (nx=ny=...=bins).

range : sequence, optional

A sequence of lower and upper bin edges to be used if the edges are not given explicitely in bins. Defaults to the minimum and maximum values along each dimension.

normed : boolean, optional

If False, returns the number of samples in each bin. If True, returns the bin density, ie, the bin count divided by the bin hypervolume.

weights : array_like (N,), optional

An array of values w_i weighing each sample (x_i, y_i, z_i, ...). Weights are normalized to 1 if normed is True. If normed is False, the values of the returned histogram are equal to the sum of the weights belonging to the samples falling into each bin.

Returns:

H : ndarray

The multidimensional histogram of sample x. See normed and weights for the different possible semantics.

edges : list

A list of D arrays describing the bin edges for each dimension.

See also

histogram
1D histogram
histogram2d
2D histogram

Examples

>>> r = np.random.randn(100,3)
>>> H, edges = np.histogramdd(r, bins = (5, 8, 4))
>>> H.shape, edges[0].size, edges[1].size, edges[2].size
((5,8,4), 6, 9, 5)

Previous topic

numpy.histogram2d

Next topic

numpy.bincount

This Page

Quick search