Code covered by the BSD License

### Highlights from Political Apportionment

5.0
5.0 | 1 rating Rate this file 1 Download (last 30 days) File Size: 4.12 KB File ID: #30245 Version: 1.2

# Political Apportionment

### Mike Sheppard (view profile)

31 Jan 2011 (Updated )

Allocates seats according to METHOD until NUM seats have been allocated

File Information
Description

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
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
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

EXAMPLE 1
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)

EXAMPLE 2
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'})

EXAMPLE 3
"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

EXAMPLE 4
"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

MATLAB release MATLAB 7.12 (R2011a)
26 May 2014 Jorge

### 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 (http://en.wikipedia.org/wiki/D%27Hondt_method#Example)

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? =(

Comment only
03 Feb 2012 Jonathan Sullivan

### Jonathan Sullivan (view profile)

Very interesting function. Well written.

01 Feb 2012 1.1

Expanded functionality, multivalued inputs

04 Apr 2012 1.2

Updated help section