| Home | Libraries | People | FAQ | More

## Struct template weighted_p_square_quantile_impl

boost::accumulators::impl::weighted_p_square_quantile_impl — Single quantile estimation with the algorithm for weighted samples.

## Synopsis

    // In header: <boost/accumulators/statistics/weighted_p_square_quantile.hpp>

    template<typename Sample, typename Weight, typename Impl>
    struct weighted_p_square_quantile_impl : public accumulator_base {
      // types
      typedef numeric::functional::multiplies< Sample, Weight >::result_type         weighted_sample;
      typedef numeric::functional::fdiv< weighted_sample, std::size_t >::result_type float_type;
      typedef array< float_type, 5 >                                                 array_type;
      typedef float_type                                                             result_type;

      // public member functions
      template<typename Args> weighted_p_square_quantile_impl(Args const &);
      template<typename Args> void operator()(Args const &);
      result_type result(dont_care) const;
      template<typename Archive> void serialize(Archive &, const unsigned int);
    };

## Description

This version of the algorithm extends the algorithm to support weighted samples. The algorithm estimates a quantile dynamically without storing samples. Instead of storing the whole sample cumulative distribution, only five points (markers) are stored. The heights of these markers are the minimum and the maximum of the samples and the current estimates of the -, - and -quantiles. Their positions are equal to the number of samples that are smaller or equal to the markers. Each time a new sample is added, the positions of the markers are updated and if necessary their heights are adjusted using a piecewise- parabolic formula.

For further details, see

R. Jain and I. Chlamtac, The P^2 algorithm for dynamic calculation of quantiles and histograms without storing observations, Communications of the ACM, Volume 28 (October), Number 10, 1985, p. 1076-1085.

### `weighted_p_square_quantile_impl` public member functions

1.     template<typename Args> weighted_p_square_quantile_impl(Args const & args);

2.     template<typename Args> void operator()(Args const & args);

3.     result_type result(dont_care) const;

4.     template<typename Archive>
         void serialize(Archive & ar, const unsigned int file_version);