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

Home » Public Forums » archive » Re: 5th & 95th Percentiles
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
Re: 5th & 95th Percentiles [message #58677] Thu, 14 February 2008 01:04
Maarten[1] is currently offline  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 Go to previous message
Spon is currently offline  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
Re: 5th & 95th Percentiles [message #58690 is a reply to message #58688] Wed, 13 February 2008 08:19 Go to previous message
chloesharrocks is currently offline  chloesharrocks
Messages: 16
Registered: January 2008
Junior Member
Thanks very much :)
Re: 5th & 95th Percentiles [message #58691 is a reply to message #58690] Wed, 13 February 2008 08:10 Go to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
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_source/idl _lib/MartinSchultz3/percentiles.pro
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: workbench project rename: bug?
Next Topic: Re: N_ELEMENTS gt 0

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

Current Time: Wed Oct 08 15:17:23 PDT 2025

Total time taken to generate the page: 0.00559 seconds