Re: vector of bin indices using histogram? [message #50782 is a reply to message #50780] |
Wed, 18 October 2006 07:47   |
Paolo Grigis
Messages: 171 Registered: December 2003
|
Senior Member |
|
|
Is it fair to add the time used for computing the min & max
of the data into the total time for the direct method? When
using real data you might already know them, or else you can
get them directly out of the histogram via the omin and
omax keywords....
You might also want to change the computation of b with
a division into a multiplication by the reciprocal (see
example below).
x=fltarr(5d7)
t=systime(/seconds)
y=x/2.
print,systime(/seconds)-t
0.82191920
t=systime(/seconds)
y=x*(1./2)
print,systime(/seconds)-t
0.33465910
Ciao,
Paolo
greg michael wrote:
> 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
>
|
|
|