klyn.math.NDArray.histogram
method
public histogram(bins as Long = 10l, bounds as Tuple<Double, Double> = null, density as Boolean = false, weights as NDArray<Double> = null, ignoreNaN as Boolean = false) as Tuple<NDArray<Double>, NDArray<Double>>
Description

Histogram of all elements, flattened without copying the source. Uniform bins include their left edge; the last bin also includes its right edge. Cost O(N log bins), O(bins) additional storage; output is Double for weighted counts.

Parameters
ParameterDescription
binsPositive number of equal-width bins.
boundsOptional finite (minimum,maximum) with positive width; otherwise inferred.
densityNormalize the integral, not the sum of heights, to one.
weightsOptional finite Double weight per source element, same shape.
ignoreNaNSkip NaN observations/weights, otherwise raise ValueException.
Returns

Tuple of 1D counts/densities and independent bin-edge array.

Throws
  • ValueException for invalid bins/bounds/weights or zero density mass.
Example

counts, edges = data.histogram(bins=20l)