[OctDev] Function mean() fails with a complex matrix

Jaroslav Hajek highegg at gmail.com
Thu Mar 5 03:53:07 CST 2009


>
> sumskipnan counts also the number of non-NaNs.
> [s,c]=sumskipnan(...)
>
> computing both s and c in a single step is beneficial for estimating
> mean, variance and other statistics.
>

well, you can do

nans = isnan (x);
x(nans) = 0;
s = sum (x, dim);
c = size (x, dim) - sum (nans);

Not exactly as fast as doing it all in a single loop, but simplistic.

>
>>
>> Besides, I think the fact that the NaN package shadows Octave's
>> built-in functions is very dangerous and confusing, even though I
>> understand the motivation. I think this package should not be
>> installed by default.
>
>
> Where do you see a danger ? Please explain.
>

It seems that sometimes users (especially windows users) get this
package unknowingly loaded. Not that this is your fault, just that it
probably shouldn't be on by default in distributions.

The more painful issue is that it makes the package less attractive to
use - for instance, if I want to use the nanmean function to get
nan-free mean, but I *don't* want the built-in mean to be shadowed
(because the replacement is slower).

OTOH, I admit sometimes it may be good to be able to just substitute
the default stats by nan-free ones.

I think it would be better to split the package in two, say, "nan" and
"nan-shadow" that would separate the two uses, because right now I
need to manually edit "path" after the package is loaded if I don't
want the default funcs to be shadowed.

cheers

-- 
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


More information about the Bug-octave mailing list