[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
(Mis)use of the is_nan_or_na() mapper function
From: |
Paul Laub |
Subject: |
(Mis)use of the is_nan_or_na() mapper function |
Date: |
Sun, 10 Oct 2004 17:38:03 -0700 |
Dear all,
Am I missing something or is there a problem with the function
is_nan_or_na? I am interested in using it to identify missing
data elements (variously marked NaN or NA -- I know, NA is
preferable).
It appears that is_nan_or_na() does not detect NAs as this
transcript shows. I am using Octave 2.1.42 in Windows 2000.
184 >> which is_nan_or_na
is_nan_or_na is a built-in mapper function
185 >> p = 1:10;
186 >> p(3) = NaN;
187 >> p(5) = NA;
188 >> isna(p) | isnan(p)
ans =
0 0 1 0 1 0 0 0 0 0 # what I expect
189 >> is_nan_or_na(p)
ans =
0 0 1 0 0 0 0 0 0 0 # not what I expect
190 >> is_nan_or_na(NaN)
ans = 1
191 >> is_nan_or_na(NA) # well ...
ans = 0
The workaround is obvious; it is command 188 above. But what gives
with is_nan_or_na()?
Paul Laub
P.S. A web search turned up this 2002 discussion issues.
http://www.octave.org/mailing-lists/help-octave/2002/581
What caught my eye is that in that exchange the function is
named with different case, ie., is_NaN_or_NA. I know that
Octave is case-sensitive.
P.P.S. Having NA is a good idea but how is it implemented?
How do you keep it separate from NaN and Inf and still use
IEEE style floating point math? I notice that sprintf("%f", NA)
returns "NaN".
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- (Mis)use of the is_nan_or_na() mapper function,
Paul Laub <=