median function [message #16417] |
Wed, 21 July 1999 00:00 |
Harald Frey
Messages: 41 Registered: March 1997
|
Member |
|
|
I see a problem in the median function and would like to get your
general opinion.
1. The median function has no /Nan option like total or mean.
IDL> a=findgen(9)
IDL> print,total(a),mean(a),median(a)
36.0000 4.00000 4.00000
IDL> a[0]=!values.f_nan
IDL> print,total(a),mean(a),median(a)
NaN NaN 4.00000
% Program caused arithmetic error: Floating illegal operand
IDL> print,total(a,/nan),mean(a,/nan),median(a,/nan)
% Keyword NAN not allowed in call to: MEDIAN
% Execution halted at: $MAIN$
IDL> print,total(a,/nan),mean(a,/nan),median(a)
36.0000 4.50000 4.00000
% Program caused arithmetic error: Floating illegal operand
2. The Nan values are not properly handled in the determination of the
median. In the first case the Nan values are interpreted as 0. and in
the second case as very large.
IDL> a=findgen(9)
IDL> a[0]=!values.f_nan
IDL> print,a
NaN 1.00000 2.00000 3.00000 4.00000
5.00000
6.00000 7.00000 8.00000
IDL> print,median(a)
4.00000
% Program caused arithmetic error: Floating illegal operand
IDL> a[1]=!values.f_nan
IDL> print,a
NaN NaN 2.00000 3.00000 4.00000
5.00000
6.00000 7.00000 8.00000
IDL> print,median(a)
6.00000
% Program caused arithmetic error: Floating illegal operand
--
=========================================================
Harald U. Frey
Space Sciences Lab phone: 510-643-3323
University of California fax: 510-643-2624
Berkeley, CA 94720-7450 email: hfrey@ssl.berkeley.edu
|
|
|