Re: 5th & 95th Percentiles [message #58677] |
Thu, 14 February 2008 01:04 |
Maarten[1]
Messages: 176 Registered: November 2005
|
Senior Member |
|
|
On Feb 13, 5:04 pm, Spon <christoph.b...@gmail.com> wrote:
> pc5 = Data( (SORT(Data) ) (5 * N_ELEMENTS(Data) / 100) )
> pc95 = Data( (SORT(Data) ) (95 * N_ELEMENTS(Data) / 100) )
Please use
compile_opt defint32, strictarr
or
compile_opt idl2
at the beginning of each function (and in your IDL startup script) and
square braces for readability. For me at least it makes my head spin.
Consider the following instead:
pc5 = Data[ (SORT(Data))[5 * N_ELEMENTS(Data) / 100] ]
At least now it is clear which is which (array indexing vs. function
calling).
If you need both pc5 and pc95, be sure to store the sorted index:
sidx = sort(data)
ndata = n_elements(data)
pc5 = data[sixd[5*ndata / 100]]
pc66 = data[sixd[66*ndata / 100]]
Maarten
|
|
|
Re: 5th & 95th Percentiles [message #58688 is a reply to message #58677] |
Wed, 13 February 2008 09:04  |
Spon
Messages: 178 Registered: September 2007
|
Senior Member |
|
|
On Feb 13, 4:10 pm, Vince Hradil <hrad...@yahoo.com> wrote:
> On Feb 13, 9:58 am, chloesharro...@gmail.com wrote:
>
>> Hello
>
>> I have an array of data which is not in order and need to find the 5th
>> & 95th percentile of this data. Is there an easy way to do this? I
>> will eventually need it to be extended to a for loop that works
>> through multiple arrays each of which have a different number of data
>> contained within them.
>
>> Thanks
>> ChloƩ
>
>> PS. I'm very inexperienced with IDL so the simpler the better!
>
> I use this:http://www.fz-juelich.de/icg/icg-1/idl_icglib/idl_sourc e/idl_lib/Mart...
pc5 = Data( (SORT(Data) ) (5 * N_ELEMENTS(Data) / 100) )
pc95 = Data( (SORT(Data) ) (95 * N_ELEMENTS(Data) / 100) )
This is blatant thievery on my part from an old newsgroup thread.
Try searching the old posts for Stein Vidar to whom all credit should
go! :-)
Good luck!
Chris
|
|
|
|
|