metrics¶
appointment.metrics provides diagnostics to analyze the results of elections, apportionments, and other political science scenarios.
Functions
poli_sci_kit.appointment.metrics.total_allocation_to_share_error()poli_sci_kit.appointment.metrics.representative_weight()poli_sci_kit.appointment.metrics.sqr_representative_weight_error()poli_sci_kit.appointment.metrics.total_representative_weight_error()poli_sci_kit.appointment.metrics.diversity_index()poli_sci_kit.appointment.metrics.effective_number_of_groups()poli_sci_kit.appointment.metrics.disproportionality_index()
Calculate the ideal share of proportions and totals.
- Parameters:
- shareint
The proportion to be checked.
- total_sharesint
The total amount of shares.
- total_allocint
The number of allocations to provide.
- Returns:
- idealfloat
The ideal share that would be allocated.
Calculate the allocation to share (advantage) ratio given to a region or group.
- Parameters:
- shareint
The proportion to be checked.
- total_sharesint
The total amount of shares.
- allocationint
The share of allocations given to the region or group.
- total_allocint
The number of allocations to provide.
- Returns:
- asrfloat
The ratio of the allocations the region or group received to their proportion of the original shares.
Calculate the squared error of an assignment’s allocation to share ratio for a population or group.
- Parameters:
- shareint
The proportion to be checked.
- total_sharesint
The total amount of shares.
- allocationint
The share of allocations given to the region or group.
- total_allocint
The number of allocations to provide.
- Returns:
- sqr_asr_errfloat
The squared of the error of the allocation to share ratio.
- poli_sci_kit.appointment.metrics.effective_number_of_groups(shares, metric_type='Laakso-Taagepera')[source]¶
Calculates the effective number of groups given vote or population distributions.
- Parameters:
- shareslist
The proportion of the original shares for the regions or groups.
- metric_typestr (default=Laakso-Taagepera, options=Golosov, Inverse-Simpson)
The type of formula to use.
- Returns:
- num_groupsfloat
A float representing the efficient number of groups given the share distributions.