ProfileTwelve

class poisson_approval.ProfileTwelve(d_type_share, d_weak_order_share=None, normalization_warning=True, ratio_sincere=0, ratio_fanatic=0, voting_rule='Approval', symbolic=False)[source]

A profile of preference with twelve types.

Parameters
  • d_type_share (dict) – E.g. {'ab_c': 0.4, 'c_ab': 0.6}. d_type_share['ab_c'] is the probability that a voter prefers candidate a, then candidate b, then candidate c, with a utility for b that is infinitely close to 1. In contrast, d_type_share['a_bc'] is the probability that a voter prefers a then b then c, with a utility for b that is infinitely close to 0.

  • d_weak_order_share (dict) – E.g. {'a~b>c': 0.2, 'a>b~c': 0.1}. d_weak_order_share['a~b>c'] is the probability that a voter likes candidates a and b equally and prefer them to candidate c.

  • normalization_warning (bool) – Whether a warning should be issued if the input distribution is not normalized.

  • ratio_sincere (Number) – The ratio of sincere voters, in the interval [0, 1]. This is used for tau().

  • ratio_fanatic (Number) – The ratio of fanatic voters, in the interval [0, 1]. This is used for tau(). The sum of ratio_sincere and ratio_fanatic must not exceed 1.

  • voting_rule (str) – The voting rule. Possible values are APPROVAL, PLURALITY and ANTI_PLURALITY.

  • symbolic (bool) – Whether the computations are symbolic or numeric.

Notes

If the input distribution d_type_share is not normalized, the profile will be normalized anyway and a warning will be issued (unless normalization_warning is False).

Examples

>>> from fractions import Fraction
>>> profile = ProfileTwelve({'ab_c': Fraction(1, 10), 'b_ac': Fraction(6, 10),
...                          'c_ab': Fraction(2, 10), 'ca_b': Fraction(1, 10)})
>>> profile
ProfileTwelve({'ab_c': Fraction(1, 10), 'b_ac': Fraction(3, 5), 'c_ab': Fraction(1, 5), 'ca_b': Fraction(1, 10)})
>>> print(profile)
<ab_c: 1/10, b_ac: 3/5, c_ab: 1/5, ca_b: 1/10> (Condorcet winner: b)
>>> profile.c_ab
Fraction(1, 5)
>>> profile.d_type_share['c_ab']  # Alternate syntax for profile.c_ab
Fraction(1, 5)
>>> profile.cab
Fraction(3, 10)
>>> profile.d_ranking_share['cab']  # Alternate syntax for profile.cab
Fraction(3, 10)
>>> profile.d_candidate_welfare
{'a': Fraction(1, 5), 'b': Fraction(7, 10), 'c': Fraction(3, 10)}
>>> profile.weighted_maj_graph
array([[0, Fraction(-1, 5), Fraction(2, 5)],
       [Fraction(1, 5), 0, Fraction(2, 5)],
       [Fraction(-2, 5), Fraction(-2, 5), 0]], dtype=object)
>>> profile.condorcet_winners
Winners({'b'})
>>> profile.is_profile_condorcet
1.0
>>> profile.has_majority_favorite  # Is one candidate 'top' in a majority of ballots?
True
>>> profile.has_majority_ranking  # Does one ranking represent a majority of ballots?
True
>>> profile.is_single_peaked  # Is the profile single-peaked?
True
>>> profile.support_in_rankings
{'abc', 'bac', 'cab'}
>>> profile.is_generic_in_rankings  # Are all rankings there?
False
>>> profile.analyzed_strategies_pure
Equilibria:
<abc: a, bac: b, cab: ac> ==> b (FF)
<abc: a, bac: ab, cab: c> ==> a (D)
<abc: ab, bac: b, cab: utility-dependent> ==> b (FF)

Non-equilibria:
<abc: a, bac: b, cab: c> ==> b (FF)
<abc: a, bac: b, cab: utility-dependent> ==> b (FF)
<abc: a, bac: ab, cab: ac> ==> a (D)
<abc: a, bac: ab, cab: utility-dependent> ==> a (D)
<abc: ab, bac: b, cab: c> ==> b (FF)
<abc: ab, bac: b, cab: ac> ==> b (FF)
<abc: ab, bac: ab, cab: c> ==> a, b (FF)
<abc: ab, bac: ab, cab: ac> ==> a (D)
<abc: ab, bac: ab, cab: utility-dependent> ==> a (D)
>>> print(profile.analyzed_strategies_pure.winners_at_equilibrium)
a, b

In the following example, one third of the voters are sincere:

>>> from fractions import Fraction
>>> profile = ProfileTwelve({'ab_c': Fraction(1, 10), 'b_ac': Fraction(6, 10),
...                          'c_ab': Fraction(2, 10), 'ca_b': Fraction(1, 10)},
...                         ratio_sincere=Fraction(1, 3))
>>> tau_sincere = profile.tau_sincere
>>> print(tau_sincere)
<ab: 1/10, ac: 1/10, b: 3/5, c: 1/5> ==> b
>>> strategy = StrategyTwelve({'abc': 'a', 'bac': 'b', 'cab': 'utility-dependent'})
>>> tau_strategic = profile.tau_strategic(strategy)
>>> print(tau_strategic)
<a: 1/10, ac: 1/10, b: 3/5, c: 1/5> ==> b
>>> tau = profile.tau(strategy)
>>> print(tau)
<a: 1/15, ab: 1/30, ac: 1/10, b: 3/5, c: 1/5> ==> b

The profile can include weak orders:

>>> profile = ProfileTwelve({'ab_c': Fraction(1, 10), 'b_ac': Fraction(6, 10)},
...                         d_weak_order_share={'a~b>c': Fraction(3, 10)})
>>> profile
ProfileTwelve({'ab_c': Fraction(1, 10), 'b_ac': Fraction(3, 5)}, d_weak_order_share={'a~b>c': Fraction(3, 10)})
>>> print(profile)
<ab_c: 1/10, b_ac: 3/5, a~b>c: 3/10> (Condorcet winner: b)
property a_bc

Share of voters with this type.

Type

Number

property a_cb

Share of voters with this type.

Type

Number

property ab_c

Share of voters with this type.

Type

Number

property abc

Share of voters with this ranking.

Type

Number

property ac_b

Share of voters with this type.

Type

Number

property acb

Share of voters with this ranking.

Type

Number

analyzed_strategies(strategies)

Analyze a list of strategies for the profile.

Parameters

strategies (iterable) – An iterator of strategies, such as a list of strategies.

Returns

The analyzed strategies of the profile.

Return type

AnalyzedStrategies

Examples

Cf. ProfileOrdinal.analyzed_strategies_ordinal().

property analyzed_strategies_group

Analyzed group strategies.

Cf. analyzed_strategies() and strategies_group. This is implemented only for profiles where we consider that there is a natural notion of group, such as ProfileNoisyDiscrete.

Type

AnalyzedStrategies

property analyzed_strategies_ordinal

Analyzed ordinal strategies.

Cf. analyzed_strategies() and strategies_ordinal.

Type

AnalyzedStrategies

property analyzed_strategies_pure

Analyzed pure strategies.

Cf. analyzed_strategies() and strategies_pure. This is implemented only for discrete profiles such as ProfileTwelve or ProfileDiscrete.

Type

AnalyzedStrategies

property b_ac

Share of voters with this type.

Type

Number

property b_ca

Share of voters with this type.

Type

Number

property ba_c

Share of voters with this type.

Type

Number

property bac

Share of voters with this ranking.

Type

Number

property bc_a

Share of voters with this type.

Type

Number

property bca

Share of voters with this ranking.

Type

Number

best_responses_to_strategy(tau, ratio_optimistic=Fraction(1, 2))

Convert best responses to a StrategyThreshold.

Parameters
  • tau (TauVector) – Tau-vector.

  • ratio_optimistic – The value of ratio_optimistic to use. Default: 1/2.

Returns

The conversion of the best responses into a strategy. Only the rankings present in this profile are mentioned in the strategy.

Return type

StrategyThreshold

property c_ab

Share of voters with this type.

Type

Number

property c_ba

Share of voters with this type.

Type

Number

property ca_b

Share of voters with this type.

Type

Number

property cab

Share of voters with this ranking.

Type

Number

property cb_a

Share of voters with this type.

Type

Number

property cba

Share of voters with this ranking.

Type

Number

property condorcet_winners

Condorcet winner(s).

Type

Winners

property contains_rankings

Whether the profile contains some rankings.

Type

bool

property contains_weak_orders

Whether the profile contains some weak orders.

Type

bool

property d_ballot_share_weak_voters_fanatic

Ballot shares due to the weak orders if they vote fanatically.

Voters of type 'a>b~c' (lovers):

  • In Approval or Plurality, they vote for a.

  • In Anti-plurality, half of them vote for ab (i.e. against c) and half of them vote for ac (i.e. against b).

Voters of type 'a~b>c' (haters):

  • In Approval or Plurality, half of them vote for a and half of them vote for b.

  • In Anti-plurality, they vote for ab (i.e. against c).

Type

dict

property d_ballot_share_weak_voters_sincere

Ballot shares due to the weak orders if they vote sincerely.

Voters of type 'a>b~c' (lovers):

  • In Approval or Plurality, they vote for a.

  • In Anti-plurality, half of them vote for ab (i.e. against c) and half of them vote for ac (i.e. against b).

Voters of type 'a~b>c' (haters):

  • In Approval or Anti-plurality, they vote for ab (i.e. against c).

  • In Plurality, half of them vote for a and half of them vote for b.

Type

dict

d_ballot_share_weak_voters_strategic(strategy)

dict : Ballot shares due to the weak orders if they vote strategically.

For voters with a weak order, strategic voting is the same as sincere voting, except in two cases:

  • For voters of type 'a~b>c' (haters)`in Plurality, who have two dominant strategies: vote for a or b.

  • For voters of type 'a>b~c' (lovers) in Anti-Plurality, who have two dominant strategies: vote against b or c (i.e. respectively for ac or ab).

property d_candidate_anti_plurality_welfare

Anti-plurality welfare of each candidate, i.e. share of voters with utility > 0.

Type

DictPrintingInOrder

property d_candidate_plurality_welfare

Plurality welfare of each candidate, i.e. share of voters with utility 1.

Type

DictPrintingInOrder

property d_candidate_relative_anti_plurality_welfare

Relative anti-plurality welfare of each candidate. This is similar to d_candidate_anti_plurality_welfare, but renormalized so that the candidate with best welfare has 1 and the one with worst welfare has 0. In math: relative_welfare = (welfare - min_welfare) / (max_welfare - min_welfare). In the case where all candidates have the same welfare, by convention, the relative welfare is 1 for all of them.

Type

DictPrintingInOrder

property d_candidate_relative_plurality_welfare

Relative plurality welfare of each candidate. This is similar to d_candidate_plurality_welfare, but renormalized so that the candidate with best welfare has 1 and the one with worst welfare has 0. In math: relative_welfare = (welfare - min_welfare) / (max_welfare - min_welfare). In the case where all candidates have the same welfare, by convention, the relative welfare is 1 for all of them.

Type

DictPrintingInOrder

property d_candidate_relative_welfare

Relative welfare of each candidate. This is similar to d_candidate_welfare, but renormalized so that the candidate with best welfare has 1 and the one with worst welfare has 0. In math: relative_welfare = (welfare - min_welfare) / (max_welfare - min_welfare). In the case where all candidates have the same welfare, by convention, the relative welfare is 1 for all of them.

Type

DictPrintingInOrder

property d_candidate_welfare

Welfare of each candidate. E.g. 'a': 0.7 means that candidate 'a' has a welfare (average utility) equal to 0.7 for the voters. Since utilities are in [0, 1], so is the welfare.

Type

DictPrintingInOrder

property d_ranking_share

Shares of rankings. E.g. 'abc': 0.3 means that a ratio 0.3 of the voters have ranking 'abc'.

Type

dict

property d_weak_order_share

Shares of weak orders. E.g. 'a~b>c': 0.3 means that a ratio 0.3 of the voters have weak order 'a~b>c'.

Type

dict

fictitious_play(init, n_max_episodes, perception_update_ratio=<function one_over_t>, ballot_update_ratio=1, winning_frequency_update_ratio=<function one_over_t>, other_statistics_update_ratio=<function one_over_t>, other_statistics_tau=None, other_statistics_strategy=None, verbose=False)

Seek for convergence by fictitious play.

Parameters
  • init (Strategy or TauVector or str) –

    The initialization.

    • If it is a strategy, it must be an argument accepted by tau(), i.e. by tau_strategic().

    • If it is a tau-vector, it is used directly.

    • If it is a string:

  • n_max_episodes (int) – Maximal number of iterations.

  • perception_update_ratio (callable or Number) – The coefficient when updating the perceived tau: tau_perceived = (1 - perception_update_ratio(t)) * tau_perceived + perception_update_ratio(t) * tau_actual. For any t from 2 to n_max_episodes included, the update ratio must be in [0, 1]. The default function is one_over_t(), which leads to an arithmetic average. However, the recommended function is one_over_log_t_plus_one(), which accelerates the convergence. If perception_update_ratio is a Number, it is considered as a constant function.

  • ballot_update_ratio (callable or Number) – The ratio of voters who update their ballot: tau_actual = (1 - ballot_update_ratio(t)) * tau_actual + ballot_update_ratio(t) * tau_response. For any t from 2 to n_max_episodes included, the update ratio must be in [0, 1]. The default function is the constant 1, which corresponds to a full update. If ballot_update_ratio is a Number, it is considered as a constant function.

  • winning_frequency_update_ratio (callable or Number) – The coefficient when updating the winning frequency of each candidate: d_candidate_winning_frequency[c] = (1 - winning_frequency_update_ratio(t)) * d_candidate_winning_frequency[c] + winning_frequency_update_ratio(t) * winning_probability[c]. The default function is one_over_t(), which leads to an arithmetic average. Note that this parameters has an influence only in case of non-convergence.

  • other_statistics_update_ratio (callable or Number) – The coefficient when updating the other statistics (cf. below).

  • other_statistics_tau (dict) – Key: name of the statistic (different from converges, tau, strategy, tau_init, n_episodes, and d_candidate_winning_frequency). Value: a function whose input is a tau-vector, and whose output is a number or a numpy array.

  • other_statistics_strategy (dict) – Key: name of the statistic (different from converges, tau, strategy, tau_init, n_episodes, d_candidate_winning_frequency and the names in other_statistics_tau). Value: a function whose input is a strategy, and whose output is a number or a numpy array.

  • verbose (bool) – If True, print all intermediate steps.

Returns

  • Key converges: bool. True if the process converges.

  • Key tau: TauVector or None. The limit tau-vector. If None, it means that the process did not converge.

  • Key strategy: StrategyThreshold or None. The limit strategy. If None, it means that the process did not converge.

  • Key tau_init: the tau-vector at initialization.

  • Key n_episodes: the number of episodes until convergence. If the process did not converge, by convention, this value is n_max_episodes.

  • Key d_candidate_winning_frequency: dict. Key: candidate. Value: winning frequency. If the process reached a limit, the winning frequencies are computed in the limit only. If the process did not converge, the frequency is computed on the whole history.

  • Others keys are those of other_statistics_tau and other_statistics_strategy. Similarly to d_candidate_winning_frequency, they give the long-run average of the corresponding statistics.

Return type

dict

Notes

Comparison between iterated_voting() and fictitious_play():

In general, you should use iterated_voting() only if you care about cycles, with the constraint that it implies having constant update ratios.

property has_majority_favorite

Whether there is a majority favorite (a candidate ranked first by strictly more than half of the voters).

Type

bool

property has_majority_ranking

Whether there is a majority ranking (a ranking shared by strictly more than half of the voters).

Type

bool

property has_majority_type

Whether there is a majority type (a type shared by strictly more than half of the voters).

Examples

>>> from fractions import Fraction
>>> profile = ProfileTwelve({'ab_c': Fraction(1, 10), 'b_ac': Fraction(6, 10),
...                          'c_ab': Fraction(2, 10), 'ca_b': Fraction(1, 10)})
>>> profile.has_majority_type
True

This does not include weak orders:

>>> profile = ProfileTwelve({'ab_c': Fraction(1, 10)}, d_weak_order_share={'b>a~c': Fraction(9, 10)})
>>> profile.has_majority_type
False
Type

bool

have_ranking_with_utility_above_u(ranking, u)[source]

Share of voters who have a given ranking and a utility for their middle candidate that is strictly above a given value.

Cf. ProfileCardinal.have_ranking_with_utility_above_u().

Examples

>>> from fractions import Fraction
>>> profile = ProfileTwelve({'ab_c': Fraction(1, 10), 'b_ac': Fraction(6, 10),
...                          'c_ab': Fraction(2, 10), 'ca_b': Fraction(1, 10)})
>>> profile.have_ranking_with_utility_above_u(ranking='cab', u=.5)
Fraction(1, 10)
>>> profile.have_ranking_with_utility_above_u(ranking='cab', u=0)
Fraction(3, 10)
>>> profile.have_ranking_with_utility_above_u(ranking='cab', u=1)
0
have_ranking_with_utility_below_u(ranking, u)[source]

Share of voters who have a given ranking and a utility for their middle candidate that is strictly below a given value.

Cf. ProfileCardinal.have_ranking_with_utility_below_u().

Examples

>>> from fractions import Fraction
>>> profile = ProfileTwelve({'ab_c': Fraction(1, 10), 'b_ac': Fraction(6, 10),
...                          'c_ab': Fraction(2, 10), 'ca_b': Fraction(1, 10)})
>>> profile.have_ranking_with_utility_below_u(ranking='cab', u=.5)
Fraction(1, 5)
>>> profile.have_ranking_with_utility_below_u(ranking='cab', u=1)
Fraction(3, 10)
>>> profile.have_ranking_with_utility_below_u(ranking='cab', u=0)
0
have_ranking_with_utility_u(ranking, u)[source]

Share of voters who have a given ranking and a utility for their middle candidate that is equal to a given value.

Cf. ProfileCardinal.have_ranking_with_utility_u().

Examples

>>> from fractions import Fraction
>>> profile = ProfileTwelve({'ab_c': Fraction(1, 10), 'b_ac': Fraction(6, 10),
...                          'c_ab': Fraction(2, 10), 'ca_b': Fraction(1, 10)})
>>> profile.have_ranking_with_utility_u(ranking='cab', u=.5)
0
is_equilibrium(strategy)[source]

Whether a strategy is an equilibrium.

Parameters

strategy (StrategyTwelve) – A strategy that specifies at least all the rankings that are present in the profile.

Returns

Whether strategy is an equilibrium in this profile.

Return type

EquilibriumStatus

Examples

>>> from fractions import Fraction
>>> profile = ProfileTwelve({'ab_c': Fraction(1, 10), 'b_ac': Fraction(6, 10),
...                          'c_ab': Fraction(2, 10), 'ca_b': Fraction(1, 10)})
>>> strategy = StrategyTwelve({'abc': 'ab', 'bac': 'b', 'cab': 'utility-dependent'})
>>> profile.is_equilibrium(strategy)
EquilibriumStatus.EQUILIBRIUM
property is_generic_in_rankings

Whether the profile is generic in rankings (contains all rankings).

Type

bool

property is_generic_in_types

Whether the profile is generic in types (contains all types).

Examples

>>> from fractions import Fraction
>>> profile = ProfileTwelve({'ab_c': Fraction(1, 10), 'b_ac': Fraction(6, 10),
...                          'c_ab': Fraction(2, 10), 'ca_b': Fraction(1, 10)})
>>> profile.is_generic_in_types
False
Type

bool

property is_profile_condorcet

Whether the profile is Condorcet. By convention, 1. means there is a strict Condorcet winner, 0.5 means there are one or more weak Condorcet winner(s), 0. means there is no Condorcet winner.

Type

float

property is_single_peaked

Whether the profile is single-peaked.

Type

bool

property is_standardized

Whether the profile is standardized. Cf. standardized_version().

Type

bool

iterated_voting(init, n_max_episodes, perception_update_ratio=1, ballot_update_ratio=1, winning_frequency_update_ratio=<function one_over_t>, other_statistics_update_ratio=<function one_over_t>, other_statistics_tau=None, other_statistics_strategy=None, verbose=False)

Seek for convergence by iterated voting.

Parameters
  • init (Strategy or TauVector or str) –

    The initialization.

    • If it is a strategy, it must be an argument accepted by tau(), i.e. by tau_strategic().

    • If it is a tau-vector, it is used directly.

    • If it is a string:

  • n_max_episodes (int) – Maximal number of iterations.

  • perception_update_ratio (Number) – Number in [0, 1]. The coefficient when updating the perceived tau: tau_perceived = (1 - perception_update_ratio) * tau_perceived + perception_update_ratio * tau_actual.

  • ballot_update_ratio (Number) – Number in [0, 1]. The ratio of voters who update their ballot: tau_actual = (1 - ballot_update_ratio) * tau_actual + ballot_update_ratio * tau_response.

  • winning_frequency_update_ratio (callable or Number) – The coefficient when updating the winning frequency of each candidate: d_candidate_winning_frequency[c] = (1 - winning_frequency_update_ratio(t)) * d_candidate_winning_frequency[c] + winning_frequency_update_ratio(t) * winning_probability[c]. The default function is one_over_t(), which leads to an arithmetic average. Note that this parameters has an influence only in case of non-convergence.

  • other_statistics_update_ratio (callable or Number) – The coefficient when updating the other statistics (cf. below).

  • other_statistics_tau (dict) – Key: name of the statistic (different from converges, tau, strategy, tau_init, n_episodes, and d_candidate_winning_frequency). Value: a function whose input is a tau-vector, and whose output is a number or a numpy array.

  • other_statistics_strategy (dict) – Key: name of the statistic (different from converges, tau, strategy, tau_init, n_episodes, d_candidate_winning_frequency and the names in other_statistics_tau). Value: a function whose input is a strategy, and whose output is a number or a numpy array.

  • verbose (bool) – If True, print all intermediate steps.

Returns

  • Key converges: bool. True if the process converges (i.e. cycle of length 1).

  • Key cycle_taus_perceived: list of TauVector. The limit cycle of perceived tau-vectors. cycle_taus_perceived[t] is a barycenter of cycle_taus_perceived[t - 1] with cycle_taus_actual[t - 1], parametrized by perception_update_ratio.

  • Key cycle_strategies: list of StrategyThreshold. The limit cycle of strategies. cycle_strategies[t] is the best response to cycle_taus_perceived[t].

  • Key cycle_taus_actual: list of TauVector. The limit cycle of actual tau-vectors. cycle_taus_actual[t] is a barycenter of cycle_taus_actual[t - 1] and the tau-vector resulting from strategies[t], parametrized by ballot_update_ratio.

  • Key tau_init: the tau-vector at initialization.

  • Key n_episodes: the number of episodes until convergence. If the process did not converge, by convention, this value is n_max_episodes.

  • Key d_candidate_winning_frequency: dict. Key: candidate. Value: winning frequency. If the process reached a limit or a periodical orbit, the winning frequencies are computed in the limit only. If the process did not converge, the frequency is computed on the whole history.

  • Others keys are those of other_statistics_tau and other_statistics_strategy. Similarly to d_candidate_winning_frequency, they give the long-run average of the corresponding statistics.

The return values cycle_taus_perceived, cycle_strategies and cycle_taus_actual are lists of the same length. If the length is 1, the process converges to this limit. If it is greater than 1, the process reaches a periodical orbit. If it is 0, by convention, it means that the process does not converge and does not reach a periodical orbit.

Return type

dict

Notes

Comparison between iterated_voting() and fictitious_play():

In general, you should use iterated_voting() only if you care about cycles, with the constraint that it implies having constant update ratios.

classmethod order_and_label(t)[source]

Order and label of a discrete type.

Cf. Profile.order_and_label().

Examples

>>> ProfileTwelve.order_and_label('ab_c')
('abc', '$r(ab\\_c)$')
>>> ProfileTwelve.order_and_label('a~b>c')
('a~b>c', '$r(a\\sim b>c)$')
classmethod order_and_label_weak(t)

Auxiliary function for order_and_label(), specialized for weak orders.

Parameters

t (object) – A weak order of the form 'a>b~c' or 'a~b>c'.

Returns

  • order (str) – The weak order itself.

  • label (str) – The label to be used for the corner of the triangle.

Examples

>>> Profile.order_and_label_weak('a~b>c')
('a~b>c', '$r(a\\sim b>c)$')
random_tau_undominated()

Random tau based on undominated ballots.

This is used, for example, in iterated_voting().

Returns

A random tau-vector. Independently for each ranking, a proportion uniformly drawn in [0, 1] of voters use one undominated ballot, and the rest use the other undominated ballot. For example, in Approval voting, voters with ranking abc are randomly split between ballots a and ab.

Return type

TauVector

share_sincere(strategy)

Share of voters that happen to cast a sincere ballot.

Parameters

strategy – An argument accepted by share_sincere_among_strategic_voters().

Returns

The ratio of voters that happen to cast a sincere ballot. This includes all kinds of voters (sincere, fanatic or strategic).

Return type

Number

property share_sincere_among_fanatic_voters

Share of fanatic voters that happen to cast a sincere ballot.

In Plurality or Anti-Plurality, this number is always 1 because fanatic voters are sincere by our definition.

In Approval, this is the proportion of fanatic voters whose ballot happen to be sincere, i.e. whose utility for their second candidate is lower or equal to 0.5.

Note that this share is relative to the share of fanatic voters: therefore, it is independent of ratio_fanatic and can be defined conventionally even if ratio_fanatic is 0, with the same computation.

Type

Number

share_sincere_among_strategic_voters(strategy)[source]

Share of strategic voters that happen to cast a sincere ballot.

Parameters

strategy (StrategyTwelve) – A strategy that specifies at least all the rankings that are present in the profile.

Returns

The ratio of sincere voters among strategic voters.

Return type

Number

Examples

>>> from fractions import Fraction
>>> profile = ProfileTwelve({'ab_c': Fraction(1, 10), 'b_ac': Fraction(6, 10),
...                          'c_ab': Fraction(2, 10), 'ca_b': Fraction(1, 10)})
>>> strategy = StrategyTwelve({'abc': 'ab', 'bac': 'b', 'cab': 'utility-dependent'})
>>> profile.share_sincere_among_strategic_voters(strategy)
1
property standardized_version

Standardized version of the profile (makes it unique, up to permutations of the candidates).

Examples

>>> from fractions import Fraction
>>> profile = ProfileTwelve({'ab_c': Fraction(1, 10), 'b_ac': Fraction(6, 10),
...                          'c_ab': Fraction(2, 10), 'ca_b': Fraction(1, 10)})
>>> print(profile.standardized_version)
<a_bc: 3/5, ba_c: 1/10, c_ba: 1/5, cb_a: 1/10> (Condorcet winner: a)
>>> profile.is_standardized
False
Type

ProfileTwelve

property strategies_group

Group strategies of the profile.

Yields

Strategy – All possible group strategies of the profile. This is implemented only for profiles where we consider that there is a natural notion of group, such as ProfileNoisyDiscrete.

Examples

Cf. ProfileNoisyDiscrete.

Type

Iterator

property strategies_ordinal

Ordinal strategies of the profile.

Yields

StrategyOrdinal – All possible ordinal strategies for this profile.

Examples

Cf. ProfileOrdinal.

Type

Iterator

property strategies_pure

pure strategies of the profile.

Yields

StrategyTwelve – All possible pure strategies of the profile.

Type

Iterator

property support_in_rankings

Support of the profile (in terms of rankings).

Type

SetPrintingInOrder of str

property support_in_types

Support of the profile (in terms of types).

Examples

>>> from fractions import Fraction
>>> profile = ProfileTwelve({'ab_c': Fraction(1, 10), 'b_ac': Fraction(6, 10),
...                          'c_ab': Fraction(2, 10), 'ca_b': Fraction(1, 10)})
>>> profile.support_in_types
{'ab_c', 'b_ac', 'c_ab', 'ca_b'}
Type

SetPrintingInOrder of str

property support_in_weak_orders

Support of the profile (in terms of weak orders).

Type

SetPrintingInOrder of str

tau(strategy)

Tau-vector associated to a strategy, with partial sincere and fanatic voting.

Parameters

strategy – An argument accepted by tau_strategic().

Returns

A share ratio_sincere of the voters vote sincerely (in the sense of tau_sincere), a share ratio_fanatic vote only for their top candidate (cf. tau_fanatic), and the rest of the voters vote strategically (in the sense of tau_strategic()). In other words, this tau-vector is the barycenter of tau_sincere, tau_fanatic and tau_strategic(strategy), with respective weights ratio_sincere, ratio_fanatic and 1 - ratio_sincere - ratio_fanatic.

Return type

TauVector

property tau_fanatic

Tau-vector associated to fanatic voting.

Returns

  • In Approval or Plurality, all voters approve of their top candidate only,

  • In Anti-plurality, all voters vote against their bottom candidate (i.e. for the other two).

Return type

TauVector

Notes

In Plurality and Anti-plurality, sincere and fanatic voting are the same. They differ only in Approval.

property tau_sincere

Tau-vector associated to sincere voting.

Returns

  • In Approval, all voters approve of their top candidate, and voters approve of their middle candidate if and only if their utility for her is strictly greater than 0.5.

  • In Plurality, all voters vote for their top candidate.

  • In Anti-plurality, all voters vote against their bottom candidate (i.e. for the other two).

Return type

TauVector

Notes

In Plurality and Anti-plurality, sincere and fanatic voting are the same. They differ only in Approval.

tau_strategic(strategy)[source]

Tau-vector associated to a strategy.

Parameters

strategy (StrategyTwelve) – A strategy that specifies at least all the rankings that are present in the profile.

Returns

Tau-vector associated to this profile and strategy strategy.

Return type

TauVector

Examples

>>> from fractions import Fraction
>>> profile = ProfileTwelve({'ab_c': Fraction(1, 10), 'b_ac': Fraction(6, 10),
...                          'c_ab': Fraction(2, 10), 'ca_b': Fraction(1, 10)})
>>> strategy = StrategyTwelve({'abc': 'ab', 'bac': 'b', 'cab': 'utility-dependent'})
>>> tau_strategic = profile.tau_strategic(strategy)
>>> print(tau_strategic)
<ab: 1/10, ac: 1/10, b: 3/5, c: 1/5> ==> b
property weighted_maj_graph

Weighted majority graph.

Type

numpy.ndarray

τ(strategy)

Tau-vector (alternate notation).

Parameters

strategy (Strategy) – A strategy that specifies at least all the rankings that are present in the profile.

Returns

Tau-vector associated to this profile and strategy strategy.

Return type

TauVector