Boost logo

Boost Users :

From: Marco Guazzone (marco.guazzone_at_[hidden])
Date: 2020-12-19 13:58:29


Hi,

On Thu, Dec 17, 2020 at 4:50 PM Dominique Devienne via Boost-users <
boost-users_at_[hidden]> wrote:

> I'm already using the accumulator below to keep track of request
> processing times of a server.
>
> using ProcAcc = acc::accumulator_set<
> double, acc::stats<
> acc::tag::min,
> acc::tag::max,
> acc::tag::mean,
> acc::tag::median,
> acc::tag::sum
> >
> >;
>
> But now I'm interested in also extracting the P90 and P99 values,
> to get insight in how much of an outlier the max could be.
>
> AFAIK, the median is the P50, but it's not readily obvious to me what tag
> to use for the P90 or P(N) in general. Could someone help please? Thanks,
> --DD
>
> PS: Does accumulator allow to keep the top(N) values as well? How?
>

The Boost.Accumulators documentation provides examples on how to compute
quantiles:

https://www.boost.org/doc/libs/1_75_0/doc/html/accumulators/user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.p_square_quantile

https://www.boost.org/doc/libs/1_75_0/doc/html/accumulators/user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.extended_p_square

https://www.boost.org/doc/libs/1_75_0/doc/html/accumulators/user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.extended_p_square_quantile

In particular, to compute both P90 and P99, together with min, max, mean,
..., just add the "extended_p_square" tag (or the
"extended_p_square_quantile" tag) and specify probabilities 0.90 and 0.99
in the constructor:

    typedef accumulator_set<double,
                                             stats<tag::extended_p_square,
                                                       tag::min,
                                                       tag::max,
                                                       tag::mean,
                                                       tag::median,
                                                       tag::sum
>
> acc_t;
    double probs[] = {0.90, 0.99);
    acc_t acc(extended_p_square_probabilities = probs);
    ...
    acc(value1);
    acc(value2);
    ...
    std::cout << "-- SUMMARY STATS:\n";
    std::cout << "Min: " << min(acc) << "\n";
    std::cout << "Max: " << max(acc) << "\n";
    std::cout << "Mean: " << mean(acc) << "\n";
    std::cout << "Median: " << median(acc) << "\n";
    std::cout << "Sum: " << sum(acc) << "\n";
    std::cout << "P90: " << extended_p_square(acc)[0] << "\n";
    std::cout << "P99: " << extended_p_square(acc)[1] << "\n";

Hope this helps.
Regards,
Marco



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net