Re: vector of bin indices using histogram? [message #50789 is a reply to message #50782] |
Wed, 18 October 2006 07:00   |
greg michael
Messages: 163 Registered: January 2006
|
Senior Member |
|
|
Thanks Ben - I never met that function before! Unfortunately, it's
using a bisection search, and comes out a little slower than the the
direct calculation:
pro test2,n
x=randomu(0,n)
h = HISTOGRAM(x, BINSIZE = 0.1, LOC = loc, MIN = 0.0)
t=systime(/seconds)
mx=max(x,min=mn)
b=fix((x-mn)/(mx-mn)*10)
print,"direct calc",systime(/seconds)-t
t=systime(/seconds)
b=VALUE_LOCATE(loc, x)
print,"value_locate",systime(/seconds)-t
end
IDL> test2,5e7
direct calc 1.5470002
value_locate 2.8750000
Well, maybe the direct calculation isn't so inefficient. But histogram
must have known those numbers during its calculation. It's a pity they
got thrown away.
Greg
|
|
|