[EM] Re: Condorcet package-wvx
Dave Ketchum
davek at clarityconnect.com
Fri Feb 25 06:35:50 PST 2005
On Fri, 25 Feb 2005 03:32:29 -0600 Daniel Bishop wrote:
> Dave Ketchum wrote:
>
>> On Fri, 25 Feb 2005 00:01:11 -0800 Russ Paielli wrote:
>>
>> ...
>>
>>> On the theoretical side, what exactly would an equal-ranking
>>> capability accomplish? Does it give the voter some significant
>>> strategic mechanism, or is it simply way for the voter to express
>>> indecision? If it's the latter, then it is completely unnecessary. If
>>> the voter truly rates the candidates as precisely equal down to the
>>> tenth decimal place, then it really shouldn't matter to him which he
>>> ranks above the other. If the decision is really that difficult, he
>>> can flip a coin. Why make the system more complicated than it needs
>>> to be?
>>
>>
>>
>> Conceded it complicates the counting, though I do not see that as major.
>
>
> It doesn't complicate the counting. Especially if you use the code from
> my website.
>
> def pairwise_matrix(ballots):
> """Return a matrix M such that M[i][j] = votes for candidate #i over #j.
>
> ballots = a list of ballots, where each ballot is a list B with each
> B[i] = the rank (1=best) of candidate #i"""
> if not ballots:
> return []
> n = len(ballots[0]) # number of candidates
> matrix = [[0] * n for i in xrange(n)]
> for ballot in ballots:
> if len(ballot) != n:
> raise ValueError("ballots have unequal lengths")
> for i in xrange(n):
> for j in xrange(n):
> if ballot[i] < ballot[j]: # i preferred over j
> matrix[i][j] += 1
>
> Note that there's not even an explicit test for equal rankings.
>
> (The GUI is simply a row of radio buttons for each candidate, each
> corresponding to a rank,)
BUT - wvx wants to count =, so redoing your last 3 lines - I think in same
syntax (I assume a large number (blank) for unranked candidates - I get
rid of pairs you do not care about, and I want to avoid, early):
for j in xrange(n):
if i != j: # avoiding the diagonal
if ballot[i] != blank: # avoiding unranked candidates
if ballot[i] < ballot[j]: # i preferred over j
matrix[i][j] += 2 # numbers doubled to avoid .5
if ballot[i] = ballot[j]: # ranked equal
matrix[i][j] += 1
--
davek at clarityconnect.com people.clarityconnect.com/webpages3/davek
Dave Ketchum 108 Halstead Ave, Owego, NY 13827-1708 607-687-5026
Do to no one what you would not want done to you.
If you want peace, work for justice.
More information about the Election-Methods
mailing list