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

Home » Public Forums » archive » vector of bin indices using histogram?
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
vector of bin indices using histogram? [message #50794] Wed, 18 October 2006 05:04
greg michael is currently offline  greg michael
Messages: 163
Registered: January 2006
Senior Member
Can anyone suggest a good way to get a vector of bin indices using
histogram?

IDL> x=randomu(0,10)
IDL> print,x
0.415999 0.0919649 0.756410 0.529700 0.930436
0.383502 0.653919 0.0668422 0.722660 0.671149

I make a histogram anyway:

IDL> h=histogram(x,binsize=.1)

And I also want to know which bin each element went into:

i.e. b=[4,0,7,5,9,3,6,0,7,6]

I could calculate that from the original data of course, but I'm sure
there must be a trick to get it out of the reverse_indices more
efficiently (when n_elements is huge).

---

While experimenting, I came across this, which is not nice...

IDL> x=randomu(0,100)*1000.
IDL> print,histogram(x,nbins=4)
31 34 34 1

The max value sometimes ends up in a bin of its own (usually this last
bin is zero - I suppose it's a rounding problem).

---

And then a question about reverse_indices - (I think it's not touched
in JD's tutorial):

why are the two parts shoved into a single array? Is there an
application where this arrangement gives some benefit? Wouldn't the
first half make more sense indexing a second separate vector without
the need for this offset?


regards,
Greg
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Snowing in Colorado
Next Topic: The proper way of catching mouse button events from a draw widget?

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

Current Time: Wed Oct 08 15:10:52 PDT 2025

Total time taken to generate the page: 0.00619 seconds