comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » median function
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
median function [message #16417] Wed, 21 July 1999 00:00
Harald Frey is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL in SPM
Next Topic: Using C++ classes with IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:38:46 PDT 2025

Total time taken to generate the page: 0.00473 seconds