metrics

appointment.metrics provides diagnostics to analyze the results of elections, apportionments, and other political science scenarios.

Functions

poli_sci_kit.appointment.metrics.ideal_share(share, total_shares, total_alloc)[source]

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.

poli_sci_kit.appointment.metrics.alloc_to_share_ratio(share, total_shares, allocation, total_alloc)[source]

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.

poli_sci_kit.appointment.metrics.sqr_alloc_to_share_error(share, total_shares, allocation, total_alloc)[source]

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.