Diversity Approximate#

agreement_index(election) dict[source]#

Calculates the agreement index of the election as defined in Faliszewski et al. ‘Diversity, Agreement, and Polarization in Elections’. Agreement for a specific pair of candidates is defined as the difference between the number of their supporters divided by the total number of voters. Agreement index of an election is the average agreement between each pair of voters.

Parameters:

election (OrdinalElection)

Returns:

‘value’: agreement index

Return type:

dict

avg_dist_to_bord(election) dict[source]#

Average swap distance between each voter and the Borda ranking.

avg_dist_to_kemeny(election)[source]#

Average swap distance between each voter and the Kemeny ranking.

avg_vote_dist(election) dict[source]#

Average swap distance between voters.

borda_std(election) dict[source]#

Standard deviation of Borda scores of all candidates.

cand_pos_dist_std(election) dict[source]#

For each pair of candidates we calculate the average difference in positions across all voters. Then we take the standard deviation of the values for all pairs.

karpov_index(election)[source]#

Geometric mean based index proposed in Karpov’s ‘Preference diversity orderings’ paper.

kkemeny_diversity_full(election) dict[source]#

Calculates the approximate k-Kemeny diversity index as defined in Faliszewski et al., ‘Diversity, Agreement, and Polarization in Elections’. It sums the values of approximate k-Kemeny distances divided by k for k from 1 to n, where n is the number of voters in the election. The values of the approximate k-Kemeny distances are obtained using the local search method (see ~kkememy_single_k function).

kkemeny_diversity_upto_r(election, r) dict[source]#

Calculates the approximate k-Kemeny diversity index as defined in Faliszewski et al., ‘Distances Between Top-Truncated Elections of Different Sizes’. It sums the values of approximate k-Kemeny distances for k from 1 to r obtained using the local search method (see ~kkememy_single_k function). In the paper, the authors use the value of r equal to 5 and they argue that it is good enough.

kkemeny_polarization(election) dict[source]#

Calculates the approximate k-Kemeny polarization index as defined in Faliszewski et al., ‘Diversity, Agreement, and Polarization in Elections’. It takes the difference between approximate k-Kemeny distance for k=1 and k=2. The values of the approximate k-Kemeny distances are obtained using the local search method (see ~kkememy_single_k function).

kkemeny_single_k(election, k, l, starting=None) dict[source]#

Calculates approximate value of k-Kemeny for single k, i.e., the sum of the swap distances between each voter and the closest out of k chosen rankings, where the k chosen rankings are set optimally. The distence is approximated as we search for the chosen rankings only from the rankings that are already present in the election as votes. Further, this distance is approximated using local search approach, where in each iteration, l rankings are changed for another rankings to optimize the sum of swap distances.

max_vote_dist(election) dict[source]#

Maximum swap distance between voters.

support_diversity(election, tuple_len) dict[source]#

Given tuple lenght k, for each k-tuple of candidates counts the number of different orderings of this tuple that can be found within the votes. Then, sums it for all k-tuples. Proposed in Hashemi and Endriss, ‘Measuring diversity of preferences in a group’.

support_pairs(election)[source]#

For each pair of candidates, a and b, checks whether a is always preferred over b. If this is the case assigns value 1 to this pair, otherwise value 2. Then sums it up for all possible pairs of candidates. Proposed in Hashemi and Endriss, ‘Measuring diversity of preferences in a group’.

support_triplets(election)[source]#

For each triplet of candidates, a, b, c, checks how many different orderings of these three candidates can be found withing the votes. Then sums it up for all possible triplets of candidates. Proposed in Hashemi and Endriss, ‘Measuring diversity of preferences in a group’.

support_votes(election) dict[source]#

Counts the number of unique votes. Proposed as a measure of diversity in Hashemi and Endriss, ‘Measuring diversity of preferences in a group’.