dohndt¶
- maelzel.distribute.dohndt(numseats, votesPerParty)[source]¶
Perform a D’Ohndt distribution
- Parameters:
numseats (
int
) – the number of seats to distribute across the partiesvotesPerParty (
list
[int
|float
]) – the votes (can be interpreted as the weight of each party) of each party.
- Return type:
list
[int
]- Returns:
the list of assigned seats per party
Example
Distribute a number of items across streams according to a set of weights.
>>> from maelzel.distribute import dohndt >>> levels = 10 >>> numstreams = 4 >>> weights = [10, 6, 5, 3] >>> assigned = dohndt(levels, weights) >>> assigned [3, 2, 2, 1]