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

Home » Public Forums » archive » Using histogram (or cghistogram) to get top X percent of distribution?
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
Using histogram (or cghistogram) to get top X percent of distribution? [message #92620] Mon, 25 January 2016 13:48 Go to next message
rjp23 is currently offline  rjp23
Messages: 97
Registered: June 2010
Member
I'm not sure if this is just me not quite understanding how histogram works.

I have a large array containing data. I want to identify the array indices of the top 10% (for example) of the data. I thought I should be able to use histogram to do this quickly but can't figure out how.

Any help much appreciated as always :-)
Re: Using histogram (or cghistogram) to get top X percent of distribution? [message #92623 is a reply to message #92620] Tue, 26 January 2016 06:37 Go to previous messageGo to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Monday, January 25, 2016 at 9:48:23 PM UTC, rj...@le.ac.uk wrote:
> I'm not sure if this is just me not quite understanding how histogram works.
>
> I have a large array containing data. I want to identify the array indices of the top 10% (for example) of the data. I thought I should be able to use histogram to do this quickly but can't figure out how.
>
> Any help much appreciated as always :-)

Hi,
I normally do something very similar to scale images: I clip the histogram around a few percent from the lowest and highest side. This can be a good reference to find those pixels...
Here is the histogram to perform the histogram percentage clipping: http://idl.marchetto.de/percentage-of-histogram/

It's not very clean, but works fine for me.

Cheers,
Helder

PS: previously I searched the cumulative histogram until I hit the percentage I wanted, but using value_locate is more efficient.
Re: Using histogram (or cghistogram) to get top X percent of distribution? [message #92625 is a reply to message #92620] Tue, 26 January 2016 07:38 Go to previous messageGo to next message
Med Bennett is currently offline  Med Bennett
Messages: 109
Registered: April 1997
Senior Member
On Monday, January 25, 2016 at 2:48:23 PM UTC-7, rj...@le.ac.uk wrote:
> I'm not sure if this is just me not quite understanding how histogram works.
>
> I have a large array containing data. I want to identify the array indices of the top 10% (for example) of the data. I thought I should be able to use histogram to do this quickly but can't figure out how.
>
> Any help much appreciated as always :-)

If all you need are the indices of the top 10% of the data, you can also just do

IDL> s = sort(data)
IDL> idx = s[round(0.9*n_elements(s)):*]
Re: Using histogram (or cghistogram) to get top X percent of distribution? [message #92626 is a reply to message #92620] Tue, 26 January 2016 07:46 Go to previous messageGo to next message
Med Bennett is currently offline  Med Bennett
Messages: 109
Registered: April 1997
Senior Member
On Monday, January 25, 2016 at 2:48:23 PM UTC-7, rj...@le.ac.uk wrote:
> I'm not sure if this is just me not quite understanding how histogram works.
>
> I have a large array containing data. I want to identify the array indices of the top 10% (for example) of the data. I thought I should be able to use histogram to do this quickly but can't figure out how.
>
> Any help much appreciated as always :-)

If all you need are the indices of the top 10% of the data, you can also just do

IDL> s = sort(data)
IDL> idx = s[round(0.9*n_elements(s))+1:*]
Re: Using histogram (or cghistogram) to get top X percent of distribution? [message #92630 is a reply to message #92620] Wed, 27 January 2016 06:26 Go to previous messageGo to next message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
I have a function for that:

http://www.ppenteado.net/idl/pp_lib/doc/pp_quartile.html

On Monday, January 25, 2016 at 1:48:23 PM UTC-8, rj...@le.ac.uk wrote:
> I'm not sure if this is just me not quite understanding how histogram works.
>
> I have a large array containing data. I want to identify the array indices of the top 10% (for example) of the data. I thought I should be able to use histogram to do this quickly but can't figure out how.
>
> Any help much appreciated as always :-)
Re: Using histogram (or cghistogram) to get top X percent of distribution? [message #92631 is a reply to message #92630] Wed, 27 January 2016 06:51 Go to previous message
pfp is currently offline  pfp
Messages: 12
Registered: July 2009
Junior Member
On Wednesday, January 27, 2016 at 7:26:12 AM UTC-7, Paulo Penteado wrote:
> I have a function for that:
>
> http://www.ppenteado.net/idl/pp_lib/doc/pp_quartile.html

Ex:
IDL> a=reverse(dindgen(20))
IDL> print,pp_quartile(a,0.9d0,index=ind,sort=s)
18.000000
IDL> print,a[s[ind:-1]]
18.000000 19.000000
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: USE of IDL in cl script for iraf???
Next Topic: DIST Function - 3D

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

Current Time: Wed Oct 08 15:14:07 PDT 2025

Total time taken to generate the page: 0.00689 seconds