Boost logo

Boost :

Subject: Re: [boost] Interest in algorithm for arithmetic mean of integers
From: Rajaditya Mukherjee (rajaditya.mukherjee_at_[hidden])
Date: 2015-09-04 10:43:37


​Hi Matt,

I am imagining such a library would be greatly useful for numerical
scientists and statisticians for precise computing. Can you give us a toy
example of how it works ?

(Sorry this is my first time posting on the boost mailing list) - Please
forgive me if I have violated any guidelines. ​

*Rajaditya Mukherjee *
*3rd Year Graduate Student*
Dept. of Computer Science and Engineering
The Ohio State University
Columbus, Ohio
Tel :- +1-(614)-271-4439
email :- rajaditya.mukherjee_at_[hidden] <mukherjee.62_at_[hidden]>,
raj_at_[hidden] <mukherjr_at_[hidden]>

On Thu, Sep 3, 2015 at 7:36 PM, Matt Calabrese <rivorus_at_[hidden]> wrote:

> AFAICT the only function for calculating arithmetic mean in boost is in the
> accumulators library and it's not really appropriate for integral types. In
> practice, properly calculating the mean for a range (especially a range
> that's only an input range but not a forward range) is surprisingly tricky
> to do in a way that avoids overflow and provides an exact result. I have a
> couple of solutions, including one that works for input ranges.
>
> Is this something that people would find useful? Is there a similar
> algorithm already implemented in boost that I'm not aware of? The approach
> I've taken yields an exact result as a mixed number and should work without
> overflow (assuming only that the range's size is able to be represented by
> its difference type). I believe the implementation that works for input
> ranges could theoretically be adapted to work with Boost.Accumulators,
> though I'm admittedly not too familiar with the library.
>
> --
> -Matt Calabrese
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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