Numbers of ranked preference votes

From: David Mertz <voting-project_at_gnosis_dot_cx>
Date: Thu Apr 29 2004 - 13:43:42 CDT

> David gave the answer anyway I wanted for ordered partial
> combinations. It'd be interesting to see what the actual numbers turn
> out to be.

Yours wish is my command (code first, then results--you can run your
own ranges, but it gets big):

$ cat ranks.py
#!/usr/bin/env python
"Compute a table of possible ranked-order votes"

def perm(N,M):
     assert M >= N
     product = 1
     for i in range(M,M-N,-1):
         product *= i
     return product

def votes(N,M):
     sum = 1 # start with no-vote case
     for i in range(1,N+1): # adjust to closed interval
         sum += perm(i,M)
     return sum

if __name__=='__main__':
     import sys
     maxslot, maxcand = map(int, sys.argv[1:])

     print "Slots:", "%8d |"*(maxslot) % tuple(range(1,maxslot+1))
     print "----------"*(maxslot+1)
     for candidates in range(1,maxcand+1):
         line = ""
         for slots in range(1,maxslot+1):
             line += "%8d |" % votes(min(slots,candidates), candidates)
         print "[%2d] " % candidates, line

$ ./ranks.py 7 16
Slots: 1 | 2 | 3 | 4 | 5 | 6 |
   7 |
------------------------------------------------------------------------
--------
[ 1] 2 | 2 | 2 | 2 | 2 | 2 |
   2 |
[ 2] 3 | 5 | 5 | 5 | 5 | 5 |
   5 |
[ 3] 4 | 10 | 16 | 16 | 16 | 16 |
  16 |
[ 4] 5 | 17 | 41 | 65 | 65 | 65 |
  65 |
[ 5] 6 | 26 | 86 | 206 | 326 | 326 |
326 |
[ 6] 7 | 37 | 157 | 517 | 1237 | 1957 |
1957 |
[ 7] 8 | 50 | 260 | 1100 | 3620 | 8660 |
13700 |
[ 8] 9 | 65 | 401 | 2081 | 8801 | 28961 |
69281 |
[ 9] 10 | 82 | 586 | 3610 | 18730 | 79210 |
260650 |
[10] 11 | 101 | 821 | 5861 | 36101 | 187301 |
792101 |
[11] 12 | 122 | 1112 | 9032 | 64472 | 397112 |
2060312 |
[12] 13 | 145 | 1465 | 13345 | 108385 | 773665 |
4765345 |
[13] 14 | 170 | 1886 | 19046 | 173486 | 1409006
|10057646 |
[14] 15 | 197 | 2381 | 26405 | 266645 | 2428805
|19726085 |
[15] 16 | 226 | 2956 | 35716 | 396076 | 3999676
|36432076 |
[16] 17 | 257 | 3617 | 47297 | 571457 | 6337217
|63994817 |
==================================================================
= The content of this message, with the exception of any external
= quotations under fair use, are released to the Public Domain
==================================================================
Received on Fri Apr 30 23:17:23 2004

This archive was generated by hypermail 2.1.8 : Fri Apr 30 2004 - 23:17:29 CDT