Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Idl-pvware > totalling data ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 5664 of 5728
Post > Topic >>

totalling data with LONG lists of indices

by Jeremy Bailin <astroconst@[EMAIL PROTECTED] > Apr 22, 2008 at 11:40 AM

In JD's magnificent histogram tutorial, there is a description of how
to total data using a separate list of indices (with possible
repeats),
along with a vague hint that "For large histograms, there are even
more
efficient ways to do this with very short or no loops (e.g. using a
histogram of the histogram)." I have exactly that situation. Because
about 90% of my indices are not repeated, I have achieved a decent
speed-up using the following code for the "single" cases ("indices",
"data", and "hist" are the index list, data list, and final result
respectively, and hist is already pre-dimensioned).

indhist = histogram(indices, omin=om, reverse_indices=indri)
dupehist = histogram(indhist, min=1, reverse_indices=duperi)
; unique cases, so we can use them to index the LHS:
if dupehist[0] gt 0 then begin
  just1 = duperi[duperi[0]:duperi[1]-1]
  hist[just1+om] += data[indri[indri[just1]]]
endif

And going with the brute-force for loop for the rest:

; loop through the rest
if n_elements(dupehist) gt 1 then begin
  multiples = duperi[duperi[1]:*]
  for j=0l,n_elements(multiples)-1 do begin
    elements = indri[indri[multiples[j]]:indri[multiples[j]+1]-1]
    hist[multiples[j]+om] += total(data[elements])
  endfor
endif


However, the loop is still going over hundreds of thousands of entries
and I can't help but suspect that another histogram and some fancy
footing with the i-vector would get rid of it. Does anyone have any
suggestions? Thanks.




 3 Posts in Topic:
totalling data with LONG lists of indices
Jeremy Bailin <astroco  2008-04-22 11:40:54 
Re: totalling data with LONG lists of indices
Conor <cmancone@[EMAIL  2008-04-24 05:36:08 
Re: totalling data with LONG lists of indices
Jeremy Bailin <astroco  2008-04-24 11:40:47 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon May 12 3:22:36 CDT 2008.