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

Home » Public Forums » archive » Re: majority voting
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: majority voting [message #65078 is a reply to message #65072] Wed, 11 February 2009 10:13 Go to previous messageGo to previous message
ben.bighair is currently offline  ben.bighair
Messages: 221
Registered: April 2007
Senior Member
On Feb 11, 11:14 am, mort canty <m.ca...@fz-juelich.de> wrote:
> Hi all,
>
> Given a 2-D array such as
>
> 0 1 1 2 1
> 0 2 1 1 1
> 1 0 2 2 1
>
> where the entries are labels, the columns represent items and the rows
> are voters, I want a IDL function that returns the majority vote labels.
> So here I should get
>
> 0 ? 1 2 1
>
> as output, where ? = "don't care". There must _not_ be a loop over
> columns. I've got a clumsy solution, but I'm sure there's an elegant one
> somewhere?

Hi,

This is incomplete as it doesn't flag the "don't care" crowd. I can't
noodle that part out without column looping. Looping would make it
easy to use something like...

for i = 0, ncol-1 do dontCare[i] = ARRAY_EQUAL(votes[i,*],votes[i,0])

but by your rules, that is out of bounds.

***BEGIN
x=[[0,1,1,2,1],$
[0,2,1,1,1],$
[1,0,2,2,1]]
sz = SIZE(x, /DIM)
votes = [[TOTAL(x EQ 0, 2)],$
[TOTAL(x EQ 1, 2)], $
[TOTAL(x EQ 2, 2)]]
mx = MAX(votes, mxIdx,dim = 2)
majority = (array_indices(sz, mxIdx, /dim))[1,*]
print, majority
***END


Cheers,
Ben
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Chnage the NO_BLOCK value in XMANAGER
Next Topic: Colorbar Labels Issue

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

Current Time: Thu Oct 23 04:37:06 PDT 2025

Total time taken to generate the page: 3.60798 seconds