Re: Mean and NaNs [message #83123 is a reply to message #83117] |
Wed, 06 February 2013 09:38  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Wednesday, February 6, 2013 8:16:35 AM UTC-8, Fab wrote:
> Hi IDLers,
>
>
>
> I know I have been annoying with NaNs lately, but is the following
> "Floating illegal operand" supposed to happen???
>
>
>
> IDL> print, !VERSION
> { x86_64 linux unix linux 8.2.2 Jan 23 2013 64 64}
> IDL> data = FINDGEN(10,10,10)
> IDL> data[5,5,*] = !VALUES.F_NAN
>
> IDL> help, mean(data, /NAN)
> <Expression> FLOAT = 499.444
> IDL> help, mean(data, DIMENSION=3, /NAN)
> <Expression> FLOAT = Array[10, 10]
> % Program caused arithmetic error: Floating illegal operand
>
> Which is related to:
> IDL> print, mean(!VALUES.F_NAN)
> NaN
> IDL> print, mean(!VALUES.F_NAN, /NAN)
> -NaN
> % Program caused arithmetic error: Floating illegal operand
>
> Is it my job to catch those cases or is something wrong?
The behavior of MEAN(x,/NAN) is to exclude NAN values from the mean calculation.
What do you expect to happen when *all* of the values are NAN?
Actually this is kind of a failure of the IDL documentation to say what happens in these cases.
CM
|
|
|