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

Home » Public Forums » archive » Incorrect behavior of /NAN
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Incorrect behavior of /NAN [message #30033] Thu, 04 April 2002 07:40 Go to previous message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
I tried to incite some interest in this last week, but had no takers,
so I'll try again. ;-)

I believe that the behavior of the TOTAL function is incorrect in
the case where all of the data are NaN and the /NAN keyword is set.

Here are several possible cases:

IDL> a = !values.f_nan
IDL> print, total([a, 1.0])
NaN
IDL> print, total([a, 1.0], /nan)
1.00000
IDL> print, total([a, a])
NaN
IDL> print, total([a, a], /nan)
0.00000

I believe that the last case is incorrect.

The documentation for /NAN says "Elements with the value NaN are treated
as missing data." In the last case there are no valid data, so how can
their sum be zero?

I think this is probably a simple error in the TOTAL algorithm.
Rather than computing the "sum of all the non-NaN values", it is
probably doing "set sum to zero and then add all non-Nan values".


For comparison, the MEAN function does not behave this way.

IDL> print, mean([a, 1.0])
NaN
IDL> print, mean([a, 1.0], /nan)
1.00000
IDL> print, mean([a, a])
NaN
IDL> print, mean([a, a], /nan)
NaN


Before I submit something (at least a question) to RSI, does anyone
have comments?

Ken Bowman
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Vector Field Plot on Irregular Grid
Next Topic: Vector Field Plot on Irregular Grid

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

Current Time: Wed Oct 08 15:33:15 PDT 2025

Total time taken to generate the page: 0.00618 seconds