CultureImpartial#
- class actinvoting.CultureImpartial(m, seed=None)[source]#
Impartial Culture.
Examples
>>> culture = CultureImpartial(m=6, seed=42) >>> culture.proba_ranking([2, 5, 0, 1, 3, 4]) 1/720 >>> culture.proba_borda([3, 2, 5, 1, 0, 4]) 1/720 >>> culture.random_ranking() array([3, 2, 5, 4, 1, 0]) >>> culture.random_borda() array([2, 4, 0, 1, 3, 5]) >>> print(culture.random_profile(n=3)) Profile((0, 1, 3, 2, 5, 4): 1, (0, 2, 4, 3, 5, 1): 1, (4, 0, 3, 2, 5, 1): 1) >>> culture.average_profile.exists_condorcet_order False >>> culture.proba_high_low(c=0, higher=set(), lower={1, 2, 3, 4, 5}) 1/6
- property average_profile#
Average profile.
- Returns:
A profile where the weight for each ranking is the corresponding probability in the culture.
- Return type:
- proba_borda(borda)[source]#
Probability of a ranking, given in Borda format.
- Parameters:
borda (List) – A ranking in Borda format. E.g. [3, 1, 2, 0] corresponds to the preference ranking 0 > 2 > 1 > 3.
- Returns:
The probability to draw this ranking.
- Return type:
float or sympy expr
- proba_high_low(c, higher, lower)[source]#
Probability that a random ranking places candidate c below certain adversaries and above the other ones.
- Parameters:
c (int) – A candidate.
higher (Set) – The adversaries that should be higher than c.
lower (Set) – The adversaries that should be lower than c. Note that together, c, higher and lower must cover all the candidates.
- Returns:
Probability that for a random ranking in this culture, candidates from higher are higher than c and those from lower are lower than c.
- Return type:
- proba_ranking(ranking)[source]#
Probability of a ranking.
- Parameters:
ranking (List) – A ranking. E.g. [0, 2, 1, 3] corresponds to the preference ranking 0 > 2 > 1 > 3.
- Returns:
The probability to draw this ranking.
- Return type:
float or sympy expr
- random_borda()[source]#
Random ranking in Borda format.
- Returns:
A random ranking in Borda format. E.g. [3, 1, 2, 0] corresponds to the preference ranking 0 > 2 > 1 > 3.
- Return type:
ndarray