Boost logo

Boost :

Subject: Re: [boost] Interest in algorithm for arithmetic mean of integers
From: Matt Calabrese (rivorus_at_[hidden])
Date: 2015-09-17 15:10:46


On Thu, Sep 17, 2015 at 9:40 AM, Seth <bugs_at_[hidden]> wrote:

> On 09/17/2015 04:13 PM, Marshall Clow wrote:
> > On Sat, Sep 5, 2015 at 12:20 PM, Matt Calabrese <rivorus_at_[hidden]>
> wrote:
> >
> > The algorithm should be able to be adapted to introduce weights. It would
> > work very similarly, only when advancing the state, it would be based on
> > the weight rather than always effectively using (D+1). Similarly, the
> > denominator would no longer always exactly match the number of elements,
> > but instead it would always match the sum of the weights that were
> > encountered. I haven't implemented this weighted variation, but it
> > shouldn't be too much of a change.
> I think Boost Accumulator already does these.
>
> E.g.
>
> http://www.boost.org/doc/libs/1_59_0/doc/html/accumulators/user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.weighted_samples

Yeah, it supports weights, if that's specifically what you're referring to,
though I thought that when I skimmed through the mean implementation it was
not implemented in a way that avoids I.E. overflow. I could have been
mistaken, though.

Also, the code just got released, so I'll put it up somewhere this weekend
if it's not redundant with what Boost.Accumulators already does somewhere.

-Matt Calabrese


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk