CulturePlackettLuce#
- class actinvoting.CulturePlackettLuce(values, seed=None)[source]#
Plackett-Luce Culture.
- Parameters:
values (List[sympy.Rational]) – Values of the Plackett-Luce model. The probability of a candidate to be ranked first is proportional to its value, the probability of the second candidate is proportional to its value divided by the sum of the remaining values, etc.
seed (int) – Random seed.
Examples
>>> values = [ ... sympy.Rational(1, 2), sympy.Rational(7, 10), sympy.Rational(3, 10), ... sympy.Rational(1, 5), sympy.Rational(1, 10), sympy.Rational(1, 5) ... ] >>> culture = CulturePlackettLuce(values=values, seed=42) >>> culture.m 6 >>> list(culture.values_normalized) [1/4, 7/20, 3/20, 1/10, 1/20, 1/10] >>> culture.proba_ranking([2, 5, 0, 1, 3, 4]) 7/2550 >>> culture.proba_borda([3, 2, 5, 1, 0, 4]) 7/2550 >>> culture.random_ranking() array([3, 1, 4, 2, 0, 5]) >>> culture.random_borda() array([4, 3, 1, 5, 0, 2])
- 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_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
- random_ranking()[source]#
Random ranking.
- Returns:
A random ranking. E.g. [0, 2, 1, 3] corresponds to the preference ranking 0 > 2 > 1 > 3.
- Return type:
ndarray
- property values_normalized#
Normalized values.
- Returns:
Normalized values, i.e., the values divided by the sum of the values.
- Return type:
List[sympy.Rational]
- property values_normalized_as_floats#
Normalized values as floats.
- Returns:
Normalized values (values_normalized) as floats.
- Return type:
ndarray