Skip to content

Allocate seats to parties or constituencies in Julia

License

Notifications You must be signed in to change notification settings

fmhahne/Apportionment.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apportionment

CI status Code Style: Blue

Proportional apportionment of seats to parties or constituencies. Available methods are SainteLague, DHondt, HuntingtonHill, and largest remainders with Droop, Hare and HagenbachBischoff quotas.

using Apportionment
votes = [10, 8, 3, 2]

apportionment(votes, 8, SainteLague())
# 4-element Vector{Int64}:
#  3
#  3
#  1
#  1

It is also possible to use biproportional apportionment with the SainteLague or DHondt methods:

votes = [770 130; 20 380; 10 190]
marginals1 = apportionment(sum(votes; dims=1), 15, DHondt())
marginals2 = [7; 5; 3]
seats = biproportional(votes, marginals1, marginals2, DHondt())
# 3×2 Matrix{Int64}:
#  7  0
#  1  4
#  0  3