joshuafr at gmail.com
Thu Nov 30 02:55:08 CST 2006
thanks for these precisions. I don't want to start a troll in this
m-l, but why numpy doesn't understand nan and masked_values together?
And a mix of them doen't work:
Then, if I have missing values in my datas, what can I do? I cannot
compute on nan, and numpy.ma doesn't recognize it. I could use isnan
to find them, but what's that?:
[ 1.00000000e+00 2.00000000e+00 1.00000000e+20],
[False False True],
nan becomes 1e+20!!! Good precision :-)
2006/11/30, Robert Kern <robert.kern at gmail.com>:
> Joshua Petterson wrote:
> > hello,
> > my question is maybe trivial, but what is the utility of numpy.NAN?
> It's a special kind of floating point number defined by the IEEE-754 floating
> point specification. It means that it is "Not a Number". It comes out of certain
> floating point operations (e.g. inf/inf) to specify that the operation actually
> has indeterminate value or that the operation is invalid.
> The alternative is to raise an exception every time such an operation occurs.
> With arrays, that kind of behavior is often undesirable since it means that all
> of your expensive calculations stop even though only one element was bad.
> Returning NaNs for those values might allow the programmer to inspect the
> results and locate the problem (if indeed it is a problem). Of course, sometimes
> you want an exception to be raised to stop execution. You can control this
> behavior with numpy.seterr().
> One of the quirks of NaNs is that they are defined to not equal anything,
> including themselves. You can use numpy.isnan() to locate NaNs. In some systems,
> NaNs are used as a way to represent missing data (people often have strong
> opinions about this, both for and against; I'd advise searching the archives of
> this list for discussions about masked arrays instead of opening that argument
> You can find more information about NaNs and other tricky bits of floating point
> from the classic paper "What Every Computer Scientist Should Know About
> Floating-Point Arithmetic":
> Robert Kern
> "I have come to believe that the whole world is an enigma, a harmless enigma
> that is made terrible by our own mad attempt to interpret it as though it had
> an underlying truth."
> -- Umberto Eco
> SciPy-user mailing list
> SciPy-user at scipy.org
More information about the SciPy-user