# Macro Library socchoice

a collection of social choice routines
Version 1.0 Sept 27, 2012

- apportion
- apportion_info
- banzhafpower
- shapleyshubikpower

### apportion

apportion(populations, seats, method)
populations: array or list of state populations
seats: number of seats to apportion
method: method to use: "hamilton", "jefferson", "adams", "webster",
"huntington", "lowndes"
returns an array giving the apportionment to each state

### apportion_info

apportion_info(populations, seats, method)
populations: array or list of state populations
seats: number of seats to apportion
method: method to use: "hamilton", "jefferson", "adams", "webster",
"huntington", "lowndes"
returns an array of:
0) the divisor
1 an array of quotas (decimal values),
2) an array of initial lower quotas (hamilton, jefferson, lowndes)
an array of initial upper quotas (adams)
an array of initial rounded quotas (webster)
an array of initial allocations (huntington)
3) an array of geometric means (huntington)
an array of decimal/whole ratios (lowndes)
an array of decimal remainders (hamilton)
nothing (others)
4) valid modified divisors, in interval notation (jefferson, adams, webster)

### banzhafpower

banzhafpower(weights, quota)
weights: list or array of voter weights
quota: voting system quota
format: defaults to decimal power index values
"counts": power counts, "frac": power index as fractions strings
calculates the Banzhaf power index for the voting system.
returns an array of power indexes
Based on http://www.hippasus.com/resources/socialsoftware/banzhaf.py (CC-BY)

### shapleyshubikpower

shapleyshubikpower(weights, quota, [format])
weights: list or array of voter weights (max: 7 voters)
quota: voting system quota
format: defaults to decimal power index values
"counts": power counts, "frac": power index as fractions strings
calculates the Shapley-Shubik power index for the voting system.
returns an array of power indexes