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

Home » Public Forums » archive » Checking my work: PERCENTILES.PRO
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
Checking my work: PERCENTILES.PRO [message #70942] Thu, 20 May 2010 17:40
MarioIncandenza is currently offline  MarioIncandenza
Messages: 231
Registered: February 2005
Senior Member
This routine, I think many people use, and it has this code:

;; Special treatment for median of data sets with even number of
;; elements: compute average between two center values
IF ABS(value[i]-0.5) LT 1.e-3 AND n MOD 2 EQ 0 AND n GT 1 THEN $
thisresult = 0.5 * ( data[ix[long(n/2)]]+data[ix[long(n/
2)+1]] ) $
ELSE $
thisresult = data[ix[ind]]

If you should happen to give PERCENTILES() a two-element array, this
will crash. What's more, if N=4, this gives the median as
MEAN(DATA[2:3]), which is clearly wrong. Should be:

thisresult = 0.5 * ( data[ix[long(n/2)-1]]+data[ix[long(n/
2)]] ) $

Does that make sense? Anyway, if I am right, you may want to check
your libraries to see if this code is in there.

--Edward H.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Negative values with incrementation
Next Topic: Re: Checking my work: PERCENTILES.PRO

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

Current Time: Wed Oct 08 19:57:26 PDT 2025

Total time taken to generate the page: 0.00490 seconds