help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: max() and min() of nan/inf


From: Jonathan King
Subject: Re: max() and min() of nan/inf
Date: Thu, 23 Sep 1999 13:03:56 -0500 (CDT)

[I sliced the to's back to the help-octave list alone.]

On Thu, 23 Sep 1999, John W. Eaton wrote:

> On 23-Sep-1999, Mike Miller <address@hidden> wrote:
> 
> | A few years ago, when MATLAB was developing their stats toolbox, they
> | added the functions nansum, nanmean, nanmedian, nanvar, nanstd, nanmax,
> | nanmin, nancov and nancorr.  These functions were identical to sum, mean,
> | median, var, std, max, min, cov and corrcoef except that they ignored NaNs
> | in the computations (they do not ignore Inf and -Inf).
> 
> | Does octave have any of those functions?
> 
> Not that I know of.

Mike and I obviously have to have lunch together soon and divvy these
up. :-)  More seriously, I've needed these recently myself, and my
previous hack around this was, um, icky.
 
> Why not just add an optional parameter to min, max, etc. that says to
> ignore NaNs?
> 
>   Y = min (X, "ignore_nan");

That would work, but it might be nice to have the nanfuncs around, too, so
that you can run code that uses the statistics toolbox under Octave.
 
> Some questions:
> 
>   * If a vector is all NaNs, should the result be [] or NaN?

I'm afraid that should probably be NaN, since it would make more sense
in situations where you're taking the mean along one dimension of a
matrix:

a = [1, 2, NaN;
     3, 4, NaN]

I think it would probably be very surprising if the answer to mean(a)
wasn't [2, 3, NaN].
 
>   * If a matrix has a column that is all NaNs, what should the result
>     be for that column?  I'd say NaN, since an individual matrix
>     element can't be [].  Then for consistency, the answer for the
>     previous question should probably also be NaN.

Dang; I should have read the second question first. :-)  What he said.

jking




---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.  To ensure
that development continues, see www.che.wisc.edu/octave/giftform.html
Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
---------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]