File Exchange

image thumbnail

Political Apportionment

version 1.2 (4.12 KB) by

Allocates seats according to METHOD until NUM seats have been allocated

1 Download


View License

APPORT Political Apportionment
SEATS = APPORT(VOTES,NUM,METHOD) takes the array of VOTES for each member and allocates seats according to METHOD until NUM seats have been allocated.
APPORT(...,MINSEATS) pre-allocates MINSEATS to each member first, guaranteeing that each member has at least MINSEATS number of SEATS. MINSEATS can either be a vector, with length equal to the number of members, or a scalar which is the same for all members. (Default is 0)
If either NUM or METHOD is multivalued it will enumerate all combinations within those parameters. An error will be given if both are multivalued.
Below is a list of available methods. METHOD can either be written out in full ('Greatest Divisor') or in abbreviated form ('GD'). Also listed are common names for the same method.
Methods available:
Greatest Divisor : d'Hondt; Jefferson; Highest Average
Smallest Divisor : Adams
Equal Proportions : Huntington; Hill; Geometric Mean
Harmonic Mean : Dean
Major Fractions : Sainte-Lague; Webster; Arithmetic Mean; Odd Numbers
Largest Remainders : Vinton; Hamilton; Hare
Abbreviated form:
ALL : All six unique methods
A : Adams
AM : Arithmetic Mean
D : Dean
DH : d'Hont
EP : Equal Proportions
GD : Greatest Divisor
GM : Geometric Mean
HH : Huntington OR Hill (equivalent)
HA : Highest Average
HAM : Hamilton OR Hare (equivalent)
HM : Harmonic Mean
J : Jefferson
LR : Largest Remainders
MF : Major Fractions
ON : Odd Numbers
SD : Smallest Divisor
SL : Sainte-Lague
V : Vinton
W : Webster
Allocate 80 seats among four parties with votes of [100 80 30 20], with minimum of 3 seats each. Compare all methods.
   apport([100 80 30 20],80,'All',3)
Compare method of Greatest Divisor with the method of Smallest Divisor of allocating 15 seats among four parties with votes of [104 62; 34 55]
   apport([104 62; 34 55],15,{'GD','SD'})
'Alabama Paradox'
"increasing the total number of items would decrease one of the shares"
   apport([2 6 6],10:13,'Hamilton')
Notice first party decreased representation from 2 to 1, even with an increase in total number of shares
'New states paradox'
"it is possible for an existing state to get more representatives than if the new state were not added"
   apport([27 39 68 ],23,'Largest Remainders')
   apport([27 39 68 6],23,'Largest Remainders')
Notice first state increased representation from 4 to 5, at the expense of one of the other two original states

Comments and Ratings (2)


Jorge (view profile)

I don't know if I'm doing this correctly, but I'm unable to reproduce the Wikipedia example for the D'Hondt method (

I try the following:
apport([100 80 30 20],8,'DH',0)

and the result is 5 3 0 0, while the example states that it should be 4 3 1 0. Incidentally if I select 'All', four of the methods show this 4 3 1 0 result, but D'Hondt is not among them. Am I doing something wrong or is there something that I'm missing here? =(

Very interesting function. Well written.



Updated help section


Expanded functionality, multivalued inputs

MATLAB Release
MATLAB 7.12 (R2011a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video