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

Home » Public Forums » archive » Re: percentile with dimension keyword
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: percentile with dimension keyword [message #76992 is a reply to message #76988] Tue, 19 July 2011 06:42 Go to previous message
ben.bighair is currently offline  ben.bighair
Messages: 221
Registered: April 2007
Senior Member
On 7/18/11 9:31 PM, JP wrote:
> Dear IDLers,
>
> The MEDIAN (i.e. 50th percentile) function has a dimension keyword.
> I need to calculate other percentiles (e.g. 5th, 95th) in a large 3D array and don't want to loop.
> Does anyone know of a function that could do that in a similar way to MEDIAN?

Hi,

Since the median operates in a rank like way, I wonder if you could
simple sort the original and determine the quantiles you want by
relative order. Perhaps like this?


x = randomn(s, 3,4,5) ; some array
ix = sort(x) ; it's ascending order indices
sx = x[ix] ; the original sorted
n = size(ix,/N_ELEMENTS) ; the number of items
p = [0.05, 0.5, 0.95] ; your quantiles (5th, 50th, and 95th)
ip = n * p ; quantiles as indices into ix
v = sx[ip] ; the quantiles as values

print, "sorted original ", sx
print, "the median ", median(x)
print, "the quantiles 5th 50th and 95th ", v


I might have fuzzy thinking on the correct way to handle the indices,
but I think it is a good start. The next step is to wrap the above in a
function that takes the array, the quantile you specify and the
dimension to operate on as arguments.

Now that I think of it, have you searched for a function called
percentile.pro? It might be worth looking for that as a starting point.



Cheers,
Ben
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: MIP from BMP Images
Next Topic: Re: cgSnaphot doesn't detect currently open windows

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

Current Time: Mon Dec 01 05:59:09 PST 2025

Total time taken to generate the page: 1.43874 seconds