import pysps
pysps.prop_allocation({"a": 1, "b": 2, "c": 3}, 5){'a': 0, 'b': 2, 'c': 3}
prop_allocation(
x,
n,
*,
initial={},
available={},
divisor=divisor_method("Jefferson/D'Hondt"),
ties='largest',
)Proportional to size allocation for stratified sampling.
x : dictThe size of each stratum.
n : intSample size.
initial : dict = {}Initial allocation for strata in ‘x’.
available : dict = {}Number of available units for each strata in x.
divisor : Callable[[int], float] = divisor_method("Jefferson/D'Hondt")A function for the divisor (highest-averages) apportionment method. The default uses the Jefferson/D’Hondt method.
ties : (largest, first) = 'largest'Either ‘largest’ to break ties in favor of the stratum with the largest size (the default), or ‘first’ to break ties in favor of the ordering of ‘x’.
: dictAllocation for each stratum in ‘x’.
Balinksi, M. L. and Young, H. P. (1982). Fair Representation: Meeting the Ideal of One Man, One Vote. Yale University Press.