mindspore.numpy.histogram_bin_edges
- mindspore.numpy.histogram_bin_edges(a, bins=10, range=None, weights=None)[source]
Function to calculate only the edges of the bins used by the histogram function.
Note
String values for bins is not supported.
- Parameters
a (Union[int, float, bool, list, tuple, Tensor]) – Input data. The histogram is computed over the flattened array.
bins ((Union[int, tuple, list, Tensor])) – 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 the 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. Default:None
.weights (Union[int, float, bool, list, tuple, Tensor], 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). This is currently not used by any of the bin estimators, but may be in the future. Default:
None
.
- Returns
Tensor, the edges to pass into histogram.
- Supported Platforms:
Ascend
GPU
CPU
- Raises
TypeError – If bins is an array and not one-dimensional.
Examples
>>> import mindspore.numpy as np >>> arr = np.array([0, 0, 0, 1, 2, 3, 3, 4, 5]) >>> print(np.histogram_bin_edges(arr, bins=2)) [0. 2.5 5. ]