Re: MEDIAN and double? [message #30772] |
Fri, 17 May 2002 19:49 |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
"Pavel A. Romashkin" <pavel_romashkin@hotmail.com> writes:
> I always thought that MEDIAN in Double is just
>
> print, (the_data[sort(the_data)])[n_elements(the_data)/2]
That works for a single number, but the nice part about MEDIAN is that
it can be applied with a sliding window, as in,
ysmooth = median(y, window)
But, if your data have double precision then YSMOOTH is not always
high enough precision to respect the original data. Or, at least,
mine didn't.
For example, consider:
IDL> print, median(1d + 2.4d-9 + [0,0]) - 1
0.00000
Whoops!
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|
Re: MEDIAN and double? [message #30775 is a reply to message #30772] |
Fri, 17 May 2002 15:18  |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
That's very strange. It appears that MEDIAN always returns a floating point
value, even if the input array is integer. I suspect this is because of the
/EVEN keyword, where it interpolates between two values if the number of points
is even. It should be smarter than that.
William Thompson
"Pavel A. Romashkin" <pavel_romashkin@hotmail.com> writes:
> I always thought that MEDIAN in Double is just
> print, (the_data[sort(the_data)])[n_elements(the_data)/2]
> but I may be wrong.
> Cheers,
> Pavel
> Craig Markwardt wrote:
>>
>> Is it true that MEDIAN only works in single precision? I've tried to
>> use a /DOUBLE keyword and it doesn't have one. This is kind of a
>> stumper since I certainly do use MEDIAN on double precision
>> data... :-)
>>
>> Craig
>>
>> --
>> ------------------------------------------------------------ --------------
>> Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
>> Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
>> ------------------------------------------------------------ --------------
|
|
|
Re: MEDIAN and double? [message #30778 is a reply to message #30775] |
Fri, 17 May 2002 14:38  |
Pavel A. Romashkin
Messages: 531 Registered: November 2000
|
Senior Member |
|
|
I always thought that MEDIAN in Double is just
print, (the_data[sort(the_data)])[n_elements(the_data)/2]
but I may be wrong.
Cheers,
Pavel
Craig Markwardt wrote:
>
> Is it true that MEDIAN only works in single precision? I've tried to
> use a /DOUBLE keyword and it doesn't have one. This is kind of a
> stumper since I certainly do use MEDIAN on double precision
> data... :-)
>
> Craig
>
> --
> ------------------------------------------------------------ --------------
> Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
> Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
> ------------------------------------------------------------ --------------
|
|
|