kopia lustrzana https://github.com/martinlackner/apportionment
Merge branch 'master' of https://github.com/martinlackner/apportionment
commit
373a9288c7
11
README.md
11
README.md
|
@ -1,17 +1,18 @@
|
|||
# A Python implementation of common apportionment methods
|
||||
|
||||
This is a collection of common apportionment methods. Apportionment has two main applications:
|
||||
to assign a fixed number of parliamentary seats to parties (proportionally to their vote count), and to assign
|
||||
representatives in a senate to states (proportionally to their population count).
|
||||
to assign a fixed number of [parliamentary seats to parties](https://en.wikipedia.org/wiki/Party-list_proportional_representation) (proportionally to their vote count), and to assign
|
||||
[representatives in a senate to states](https://en.wikipedia.org/wiki/United_States_congressional_apportionment) (proportionally to their population count).
|
||||
A recommendable overview of apportionment methods can be found in the book "Fair Representation" by Balinski and Young [2].
|
||||
|
||||
The following methods are implemented:
|
||||
The following apportionment methods are implemented:
|
||||
* the largest remainder method (or Hamilton method)
|
||||
* the class of divisor methods including
|
||||
- D'Hondt (or Jefferson)
|
||||
- Sainte-Laguë (or Webster)
|
||||
- Huntington-Hill
|
||||
- Adams
|
||||
* the Quota method [1]
|
||||
* the quota method [1]
|
||||
|
||||
|
||||
## How-to
|
||||
|
@ -32,3 +33,5 @@ Another example can be found in [example.py](example.py).
|
|||
## References
|
||||
|
||||
[1] Balinski, M. L., & Young, H. P. (1975). The quota method of apportionment. The American Mathematical Monthly, 82(7), 701-730.
|
||||
|
||||
[2] Balinski, M. L., & Young, H. P. (1982). Fair Representation: Meeting the Ideal of One Man, One Vote. Yale University Press, 1982. (There is a second edition from 2001 by Brookings Institution Press.)
|
||||
|
|
|
@ -177,7 +177,7 @@ def quota(distribution, seats, parties=string.ascii_uppercase, verbose=True):
|
|||
for i in range(len(distribution))]
|
||||
# check if upper quota is violated
|
||||
for i in range(len(distribution)):
|
||||
if representatives[i] > math.ceil(float(distribution[i])*k/sum(distribution)):
|
||||
if representatives[i] >= math.ceil(float(distribution[i])*k/sum(distribution)):
|
||||
quotas[i] = 0
|
||||
chosen = [i for i in range(len(distribution))
|
||||
if quotas[i] == max(quotas)]
|
||||
|
|
Ładowanie…
Reference in New Issue