mindspore.numpy.histogramdd
- mindspore.numpy.histogramdd(sample, bins=10, range=None, weights=None, density=False)[source]
Computes the multidimensional histogram of some data.
Note
Deprecated numpy argument normed is not supported.
- Parameters
sample (Union[list, tuple, Tensor]) –
The data to be histogrammed, either (N, D) array, or (D, N) array_like. Note the unusual interpretation of sample when an array_like:
When an array, each row is a coordinate in a D-dimensional space - such as
histogramdd(np.array([p1, p2, p3]))
.When an array_like, each element is the list of values for single coordinate - such as
histogramdd((X, Y, Z))
.The first form should be preferred.
bins (Union[int, tuple, list], optional) –
The bin specification:
A sequence of arrays describing the monotonically increasing 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 (Union[list, tuple], optional) – A sequence of length D, each an optional
(lower, upper)
tuple giving the outer bin edges to be used if the edges are not given explicitly in bins. An entry of None in the sequence results in the minimum and maximum values being used for the corresponding dimension. The default, None, is equivalent to passing a tuple of D None values.weights (Union[list, tuple, Tensor], optional) – An array with shape (N,) of values w_i weighing each sample
(x_i, y_i, z_i, …)
.density (boolean, optional) – If False, the default, returns the number of samples in each bin. If True, returns the probability density function at the bin,
bin_count / sample_count / bin_volume
.
- Returns
(Tensor, list of Tensor), the values of the histogram and the bin edges.
- Raises
ValueError – if range does not have the same size as the number of samples.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> from mindspore import numpy as np >>> sample = np.arange(15).reshape(5, 3) >>> print(sample) [[ 0 1 2] [ 3 4 5] [ 6 7 8] [ 9 10 11] [12 13 14]] >>> print(np.histogramdd(sample, bins=(2, 3, 4))) (Tensor(shape=[2, 3, 4], dtype=Float32, value= [[[ 1.00000000e+00, 1.00000000e+00, 0.00000000e+00, 0.00000000e+00], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]], [[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [ 0.00000000e+00, 0.00000000e+00, 1.00000000e+00, 0.00000000e+00], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 2.00000000e+00]]]), [Tensor(shape=[3], dtype=Float32, value= [ 0.00000000e+00, 6.00000000e+00, 1.20000000e+01]), Tensor(shape=[4], dtype=Float32, value= [ 1.00000000e+00, 5.00000000e+00, 9.00000000e+00, 1.30000000e+01]), Tensor(shape=[5], dtype=Float32, value= [ 2.00000000e+00, 5.00000000e+00, 8.00000000e+00, 1.10000000e+01, 1.40000000e+01])])