Re: MEDIAN filtering and why it's not working [message #12073 is a reply to message #12061] |
Wed, 10 June 1998 00:00  |
David Foster
Messages: 341 Registered: January 1996
|
Senior Member |
|
|
T Bowers wrote:
>
> Hi,
> How come
>
> print, median([0.0,1.0,1.5,2.0,5.0,6.0], 3, /EVEN)
>
> prints
> 0.00000 1.00000 1.50000 2.00000 5.00000 6.00000
>
> instead of
> 1.00000 1.00000 1.00000 5.00000 5.00000 5.00000
>
> Doesn't look like it's filtering anything to me, no matter what
> I set the filter width to.
>
> Actually, I'd really like it to print
> 1.00000 5.00000
> just the median of each filter width. I'm trying to filter spikes in
> time series data.
> I'm using IDL 5.02 and win95
Check the Online help for info on MEDIAN(), because you are a bit
confused as to how it works. For example, the median of [1.0,1.5,2.0]
is 1.5, not 1.0 as you suggest. With a width of 3, each element
of your median array will be the median of itself and its two
neighbors. Since your array is monotonically increasing, each
element will be it's "own" median value.
If you want only the median values from every 3 elements, then you
can use:
index = lindgen(n_elements(array))
ind3 = where(index mod 3 eq 0)
median3 = (median(array, 3))[ind3]
Hope this helps.
Dave
>
> tia,
> todd bowers
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
|
|
|