Profile

class poisson_approval.Profile(voting_rule='Approval', symbolic=False)[source]

A profile of preference (abstract class).

Parameters:
  • voting_rule (str) – The voting rule. Possible values are APPROVAL, PLURALITY and ANTI_PLURALITY.
  • symbolic (bool) – Whether the computations are symbolic or numeric.
abc

Share of voters with this ranking.

Type:Number
acb

Share of voters with this ranking.

Type:Number
analyzed_strategies(strategies)[source]

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().

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
analyzed_strategies_ordinal

Analyzed ordinal strategies.

Cf. analyzed_strategies() and strategies_ordinal.

Type:AnalyzedStrategies
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
bac

Share of voters with this ranking.

Type:Number
bca

Share of voters with this ranking.

Type:Number
best_responses_to_strategy(d_ranking_best_response)[source]

Convert best responses to a StrategyThreshold.

Parameters:d_ranking_best_response (dict) – Key: ranking. Value: BestResponse.
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
cab

Share of voters with this ranking.

Type:Number
cba

Share of voters with this ranking.

Type:Number
condorcet_winners

Condorcet winner(s).

Type:Winners
contains_rankings

Whether the profile contains some rankings.

Type:bool
contains_weak_orders

Whether the profile contains some weak orders.

Type:bool
d_ballot_share_weak_voters_fanatic

Ballot shares due to the weak orders if they vote fanatically

Voters of the type 'a>b~c':

  • 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 the type 'a~b>c':

  • 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
d_ballot_share_weak_voters_sincere

Ballot shares due to the weak orders if they vote sincerely

Voters of the type 'a>b~c':

  • 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 the type 'a~b>c':

  • 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_ranking_share

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

Type:dict
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
has_majority_favorite

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

Type:bool
has_majority_ranking

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

Type:bool
is_equilibrium(strategy)[source]

Whether a strategy is an equilibrium in this profile.

Parameters:strategy (Strategy) – 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
is_generic_in_rankings

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

Type:bool
is_profile_condorcet

Whether the profile is Condorcet. 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
is_single_peaked

Whether the profile is single-peaked.

Type:bool
is_standardized

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

Type:bool
classmethod order_and_label(t)[source]

Order and label of a discrete type.

Helper method for the ternary plots. Implemented only for subclasses of Profile where the initialization is made with a dictionary that maps types to voter share, such as ProfileNoisyDiscrete or ProfileOrdinal, but unlike ProfileHistogram (where a second dictionary is needed for the histograms).

Parameters:t (object) – A type. Any type that is accepted at a key in the initialization dictionary.
Returns:
  • order (str) – The ranking or weak order.
  • label (str) – The label to be used for the corner of the triangle.

Examples

Cf. ProfileNoisyDiscrete.order_and_label().

classmethod order_and_label_weak(t)[source]

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()[source]

Random tau based on undominated ballots.

This is used, for example, in ProfileCardinal.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
standardized_version

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

Type:Profile
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
strategies_ordinal

ordinal strategies of the profile.

Yields:StrategyOrdinal – All possible ordinal strategies for this profile.

Examples

Cf. ProfileOrdinal.

Type:Iterator
strategies_pure

pure strategies of the profile.

Yields:Strategy – All possible pure strategies of the profile. This is implemented only for discrete profiles such as ProfileTwelve or ProfileDiscrete.

Examples

Cf. ProfileDiscrete.

Type:Iterator
support_in_rankings

Support of the profile (in terms of rankings).

Type:SetPrintingInOrder of str
support_in_weak_orders

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

Type:SetPrintingInOrder of str
tau(strategy)[source]

Tau-vector associated to this profile and a given strategy.

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
weighted_maj_graph

Weighted majority graph.

Type:np.ndarray
τ(strategy)[source]

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