Comment on median(x) and NaN
Ben Abbott
bpabbott at mac.com
Thu Jan 17 06:12:29 CST 2008
On Jan 17, 2008, at 12:15 AM, Michael D Godfrey wrote:
> It appears that the Octave sort behavior was done
> to match Matlab. Thus for
> x= [1,2,3,4,NaN,NaN,NaN,NaN,5,6,7,8,9];
> Octave and Matlab sort(x) return
> 1 2 3 4 5 6 7 8 9 NaN NaN
> NaN NaN
> And, for sort(x,'descend'), both return
> NaN NaN NaN NaN 9 8 7 6 5 4 3
> 2 1
>
> But, for the above array, or any vector containing NaN,
> Matlab median() returns NaN. Octave median() returns 7 for
> both median(sort(x)) and median(sort(x,'descend')). Also,
> mean(x) returns NaN in both Octave and Matlab.
>
> There has been some recent discussion about median(), so this
> observation should be considered in making any changes.
>
> It seems to me that the sort behavior is not consistent with
> the intent of the IEEE spec. However, this may be another case where
> "Matlab compatibility (right or wrong)" may be the better choice,
> at least for now.
>
> The Matlab that I used for this is 7.5.0 (R2007b).
>
> Michael
Good point.
I'm still working on the quantile algorithm. I'll add this *feature*
to the list.
Ben
More information about the Bug-octave
mailing list