hist_nd question [message #52936] |
Mon, 05 March 2007 07:17 |
Wox
Messages: 184 Registered: August 2006
|
Senior Member |
|
|
Hi all,
I have been using JD's hist_nd before, but I just found something
strange. Maybe this is already corrected somewhere or maybe this is a
"feature", but N-dimensional points falling outside of the given
min/max boundries, are mapped to the first and the last bin. To
clarify:
IDL> ha=hist_nd([[0,1,0],[2,0,1],[3,2,2],[0,1,1],[-1,0,0]],
Min=[0,0,0], Max=[2,2,2],1) & print,ha
1* 0 0
1 0 0
0 0 0
0 0 1
1 0 0
0 0 0
0 0 0
0 0 0
0 0 0
The 1* must be 0.
The fix is simple: change two lines.
h=(nbins[s[0]-1]-1)<long((V[s[0]-1,*]-mn[s[0]-1])/bs[s[0]-1]) >0L
=>
h=nbins[s[0]-1]<long((V[s[0]-1,*]-mn[s[0]-1])/bs[s[0]-1])>-1L
h=nbins[i]*h+((nbins[i]-1)<long((V[i,*]-mn[i])/bs[i])>0L)
=>
h=nbins[i]*h+(nbins[i]<long((V[i,*]-mn[i])/bs[i])>-1L)
But since this function was written be JD and presented on Fanning's
website, I obviously started doubting myself :-). Hence the question:
is this a bug or a feature? And by changing these two lines, are there
negative consequences which I overlooked?
|
|
|