Package elections :: Module condorcet
[frames] | no frames]

Module condorcet

source code

Implement all of the functions for computing the Condorcet winner and lower bound.

Functions
numpy.matrix
build_condorcet(election)
Build and return a Condorcet matrix from an Election.
source code
number
condorcet_winner(m)
Compute and return the Condorcet winner from the Condorcet matrix.
source code
number
condorcet_lb(m, winner=None)
Return a lower bound on the Condorcet margin.
source code
Variables
  __package__ = 'elections'
Function Details

build_condorcet(election)

source code 

Build and return a Condorcet matrix from an Election.

This assumes the children of root are the integers 1, 2, ..., k. The matrix returned is 0-based.

Parameters:
Returns: numpy.matrix
Returns the 0-based Condorcet matrix representing the election.

condorcet_winner(m)

source code 

Compute and return the Condorcet winner from the Condorcet matrix.

Parameters:
  • m (numpy.matrix) - The Condorcet matrix.
Returns: number
The winner.

The winner returned is 1-based, unlike the matrix.

condorcet_lb(m, winner=None)

source code 

Return a lower bound on the Condorcet margin.

This is the minimum pair-wise margin between the Condorcet winner and the other candidates. If there is no Condorcet winner, then 0 is returned.

Parameters:
  • m (numpy.matrix) - The Condorcet matrix.
  • winner (number) - The winner. This is computed if None.
Returns: number
Returns the winner or 0 if there is no Condorcet winner.