G'day all,

On Wed, 18 Feb 2009 12:41:27 -0500
Stavros Macrakis <macra...@alum.mit.edu> wrote:

> Hmm.  Why not use the same method to guarantee the same result?  

Hmm, I did not look at the source code but, potentially, sum() could
use some tricks to reduce rounding errors further that would not be
available to cumsum(); e.g. sorting the data before adding summing
them; or grouping them into groups of roughly similar magnitude and
then sum group-by-group.  So it does may be counter-productive to use
the same method.....

> Or at least document the possibility that cumsum(x)[length(x)] !=
> sum(x)... that seems like an easy trap to fall into.

But this is already documented, isn't it?  FAQ 7.31. ;-))

Cheers,

        Berwin

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to