[R] cumsum vs. sum

Martin Maechler maechler at stat.math.ethz.ch
Wed Feb 18 17:39:03 CET 2009

>>>>> "SM" == Stavros Macrakis <macrakis at alum.mit.edu>
>>>>>     on Wed, 18 Feb 2009 10:00:40 -0500 writes:

    SM> Nice!  Glad to hear it. It sounds as though it is still possible for
    SM> cumsum(x)[length(x)] to not be exactly equal to sum, though?

Well, possible, probably yes, platform-dependently; 
However I vaguely remember that I didn't see one such case in the few
experiments I did.


    SM> On Wed, Feb 18, 2009 at 8:03 AM, Martin Maechler
    SM> <maechler at stat.math.ethz.ch> wrote:
    SM> ...
    >> o   cumsum(x) and cumprod(x) for double precision x now use a long
    >> double accumulator where available and so more closely match
    >> sum() and prod() in potentially being more accurate.

More information about the R-help mailing list