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

Home » Public Forums » archive » Re: Filtering out NaNs
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: Filtering out NaNs [message #8519 is a reply to message #8502] Thu, 20 March 1997 00:00 Go to previous messageGo to previous message
sritcey is currently offline  sritcey
Messages: 5
Registered: March 1997
Junior Member
Iarla Kilbane-Dawe asked about filetering out NaN's.

The issue of detecting NaNs is a bit of a swamp; having just come out of
the muck a while ago, I'd like to add my two cents. [I'm running PVWave,
so some of the following may not apply to IDL.]

Stein Vidar suggested using that magical property of IEEE NaN's that they
are not even equal to themselves:

b= a (where (a eq a)) ; exclude NaN's

while Ken Bowman suggested using the FINITE function:

b= a (finite (a)) ; exclude .... what? (see below)

In IEEE floating point specification, in addition to ordinary floating
point numbers, there are a bunch of special values, among them NaN (``not
a number'') and infinity, both positive and negative.

Vidar's technique will exclude NaN's, but not infinities. The approach is
widely used, but has been criticized in traditional languages like Fortran,
where it has been known to fail because the compiler optimized it away.
There is a general consensus that a function to test for NaN-ship is
desirable in any language which supports IEEE arithmetic.

Unfortunately, FINITE is not that function. In my PV-Wave documentation,
FINITE is described as ``Returns a value indicating if the input is finite
or not ... [FINITE(x)] returns 1 if x is infinite or ... NaN''. Thus
it seems to do more than the original poster wanted, since it not only
flags NaNs, it also flags infinities.

Now maybe that's OK; probably you want to exclude both pathologies when
cleaning up a data set. Unfortunately, the PV-Wave implementation is
at odds with the documentation (PV-WAVE v6.01 (Advantage), IRIX Release
5.3):

Consider
WAVE> mach= machine (/float)
WAVE> a= [0.0, 1.0, mach.nan, 3.0, mach.neg_inf]
WAVE> goodguys= finite (a)
% Program caused arithmetic error: Floating illegal operand
% Detected at $MAIN$ (FINITE).
WAVE> print, goodguys
1 1 1 1 0

So at least on the platform mentioned, FINITE cannot be used to flag
NaN's. Question: Is the documentation wrong, or the implementation?
I personally think that the implementation does what I would prefer;
I would like to see a function ISNAN added.

What exactly does FINITE do on IDL?

Stephen Ritcey (902)494-3313 (voice) (902)494-5191 (fax)
Physics Dept., Dalhousie Univ., Halifax, N.S., Canada B3H 3J5
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Time Series Analysis
Next Topic: Re: Anything better than ANNOTATE?

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

Current Time: Sat Oct 11 07:00:59 PDT 2025

Total time taken to generate the page: 0.09020 seconds