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

Home » Public Forums » archive » histogram & reverse_indices
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
histogram & reverse_indices [message #30071] Tue, 09 April 2002 12:15 Go to previous message
Ken Mankoff is currently offline  Ken Mankoff
Messages: 158
Registered: February 2000
Senior Member
Hi,

As you may have guessed from the subject, I have a question about
histogram and reverse indices...

I have a 2D array made up of n quadruplets. Ex:
array =[[1,1,1,2], $
[1,1,1,1], $
[3,4,3,2], $
[3,3,0,0], $
[5,5,0,5]]

I want my algorithm to do the following: Return the index of all the
quadruplets that have at least 3 out of 4 numbers equal to each other
(i.e. for the above array, it should return [0,1,4].

I can do it in a for-loop as follows:

for i=0,n_elements(array[0,*])-1 do begin
quad = array[*,i]
hist = histogram( quad )
hist = hist[ where( hist ne 0 ) ]
if ( max( hist ) gt 3 then print, 'good' else print, 'bad'
endfor

But I think there is a way to do this without a for loop. Either using
reverse_indices, or where(), I just cannot see it. Can you?

-k.

--
Kenneth Mankoff
LASP://303.492.3264
http://lasp.colorado.edu/~mankoff/
http://lasp.colorado.edu/snoe/
http://lasp.colorado.edu/mars/
http://lasp.colorado.edu/marsrobot/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: basic soubt with fltarr
Next Topic: Ascertaining Keyword Parameters

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

Current Time: Wed Oct 08 10:44:22 PDT 2025

Total time taken to generate the page: 0.00481 seconds