class pyinterp.StreamingHistogram(values: Array | ndarray, weights: ndarray | Array | None = None, axis: int | Iterable[int] | None = None, bin_count: int | None = None, dtype: dtype | None = None)[source]#

Bases: object

Streaming histogram.

The bins in the histogram have no predefined size, so that as values are pushed into the histogram, bins are added and merged as soon as their numbers exceed the maximum allowed capacity. A particularly interesting feature of streaming histograms is that they can be used to approximate quantiles without sorting (or even storing) values individually. The histograms can be constructed independently and merged, making them usable with Dask.

  • values

    Array containing numbers whose statistics are desired.


    NaNs are automatically ignored.

  • weights – An array of weights associated with the values. If not provided, all values are assumed to have equal weight.

  • axis – Axis or axes along which to compute the statistics. If not provided, the statistics are computed over the flattened array.

  • bin_count – The maximum number of bins to use in the histogram. If the number of bins exceeds the number of values, the histogram will be trimmed. Default is None, which will set the number of bins to 100.

  • dtype – Data type of the returned array. By default, the data type is numpy.float64.

See also

Yael Ben-Haim and Elad Tom-Tov, A Streaming Parallel Decision Tree Algorithm, Journal of Machine Learning Research, 11, 28, 849-872,


If you do not want to estimate the quantiles of the dataset, use the class DescriptiveStatistics which will give you more accurate results.

Public Methods


Returns the histogram bins.


Returns the count of samples.


Returns the kurtosis of samples.


Returns the maximum of samples.


Returns the mean of samples.


Returns the minimum of samples.


Returns the q quantile of samples.


Returns the number of bins allocated to calculate the histogram.


Returns the skewness of samples.


Returns the standard deviation of samples.


Returns the sum of weights.


Returns the variance of samples.

Special Methods


Adds a new histogram to the current one.