Steffen Müller > Math-SZaru > Math::SZaru::QuantileEstimator

# NAME

Math::SZaru::QuantileEstimator - Quantile estimation based on Munro-Paterson algorithm

# SYNOPSIS

```  use Math::SZaru::QuantileEstimator;
my \$ue = Math::SZaru::QuantileEstimator->new(\$maxelems);
# add many more elems using add_elem ...
my \$inserted_elems_count = \$ue->tot_elems;
my \$estimated_unique_count = \$ue->estimate();```

# DESCRIPTION

`Math::SZaru::QuantileEstimator` provides a statistical estimate of quantiles in a large data set (or stream). It uses the algorithm published by Munro and Paterson: Munro & Paterson, "Selection and Sorting with Limited Storage", Theoretical Computer Science, Vol 12, p 315-323, 1980.

# METHODS

## new

Constructor. Expects an integer indicating the number of quantiles to calculate. In a nutshell, passing 101 will mean that the return value of the `estimate` call (see below) will return a list of min, 1st-percentile, 2nd-percentile, ..., 99th-percentile, max (min + 100 = 101). Other values cause the space between min and max to be differently divided. Asking for only two quantiles will just yield min/max to be tracked. Asking for three quantiles will add the median (50th percentile).

Given a floating point number, adds the number to the QuantileEstimator.

Same as `add_elem`, but accepts an arbitrary list of numbers to insert into the estimator at once.

## tot_elems

Returns the total count of the number of elements that were added to the estimator.

## estimate

Returns the estimated quantiles in a raference to an array as described in the `new` documentation above.

Math::SZaru

# AUTHOR

Steffen Mueller, <smueller@cpan.org>

`  http://www.apache.org/licenses/LICENSE-2.0`