comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » mean() function
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: mean() function [message #46991 is a reply to message #46938] Thu, 12 January 2006 09:07 Go to previous message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article <ywkuzmm1l7bv.fsf@snowblower.colorado.edu>, savoie@nsidc.org
wrote:

> "Maarten" <maarten.sneep@knmi.nl> writes:
>
>> And the reason you need that page, is in part because IDL uses the
>> moment routine described in Numerical Recipes (take total first, divide
>> later), instead of a proper running average, like the GNU scientific
>> library does.
>>
>> However, since looping is slow in IDL, you don't want to implement that
>> in IDL, so the next best thing is to have that page.

The situation to avoid is adding values with different magnitudes. That
results in a loss of precision.

For example, summing a large number of values with similar magnitudes
will eventually result in adding small values to large values.

There are several tricks one can use to avoid this, particularly in the
case where all the values have similar magnitudes. The simplest is to
assume that the mean is close to the first value. Subtract the first
value from each value before accumulating, compute the mean, then add
the first value back into the total. Alternatively, compute a first
approximation to the mean the naive way, then recompute the mean by
subtracting the approximate mean from each value before summing. This
requires two passes through the data, so the tradeoff is computational
time and precision.

Ken Bowman
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: mean() function
Next Topic: ASP.NET vs JSF

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 13:18:39 PDT 2025

Total time taken to generate the page: 1.68113 seconds