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

Home » Public Forums » archive » Re: Calculating mean (was mean and sdev)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Calculating mean (was mean and sdev) [message #11037] Thu, 05 March 1998 00:00
nospam is currently offline  nospam
Messages: 21
Registered: November 1997
Junior Member
In article <34FE5D52.70D510F8@linmpi.mpg.de> Kevin Ivory <Kevin.Ivory@linmpi.mpg.de> writes:

> Kevin Spencer wrote:
>> they get rid of stdev in the first place? And calculating the mean
>> is trivial; just use total(x)/n_elements(x).
>
> It is not as trivial as that. If your array contains NaNs, you will
> always get a NaN as a result. In many cases you will want to have
> the mean of the finite values.

I just looked at the source for moment in IDL 5.0.2, and it appears
that it does not correctly handle NaNs.

TypeX = SIZE(X)

nX = TypeX[TypeX[0]+2]
Mean = DATOTAL(X, Double = Double) / nX

the function DATOTAL just calls total() and massages the return type.
The documentation for total() says that you have to set /NAN to have
it treat NaNs as missing data, and the call to total does not do that,
nor does it remove the NaNs from the count of elements.

scott

--
Scott Stuart
stuart at ll mit edu
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Where is IDLgrTesselator?
Next Topic: Re: IDL imaging command?

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

Current Time: Sat Oct 11 09:27:30 PDT 2025

Total time taken to generate the page: 1.36198 seconds