XyyToProfile
- class poisson_approval.XyyToProfile(cls, left_ranking, right_ranking, d_type_fixed_share=None, **kwargs)[source]
Map a point (x, y1, y2) to a profile (for binary plots).
- Parameters
cls (class) –
ProfileDiscrete
orProfileNoisyDiscrete
.left_ranking (str) – A ranking, whose share is maximal on the left (resp. on the right).
right_ranking (str) – A ranking, whose share is maximal on the left (resp. on the right).
d_type_fixed_share (dict) – Key: a type that is suitable for the kind of profile used. Value: a share of voters.
kwargs – Other keyword arguments are passed to the profile. E.g.
voting_rule
,ratio_fanatic
, etc.
Notes
An XyyToProfile object is a callable. When called, it takes three parameters x, y1, y2 in the interval [0, 1]. It outputs the profile defined by:
The class is given by cls,
According to d_type_fixed_share, some types are assigned fixed shares of voters.
The other voters are distributed between
left_ranking
andright_ranking
, in respective proportions that are given by 1 - x and x.The voters of left_ranking have a utility y1 for their second candidate.
The voters of right_ranking have a utility y2 for their second candidate.
Examples
Typical usage:
>>> xyy_to_profile = XyyToProfile( ... ProfileNoisyDiscrete, ... d_type_fixed_share={('abc', 0.4, 0.01): Fraction(2, 11)}, ... left_ranking='bca', right_ranking='cab', ... noise=0.01) >>> profile = xyy_to_profile(x=Fraction(4, 9), y1=0.7, y2=0.9) >>> print(profile) <abc 0.4 ± 0.01: 2/11, bca 0.7 ± 0.01: 5/11, cab 0.9 ± 0.01: 4/11>
The types with variable share and fixed share may overlap:
>>> xyy_to_profile = XyyToProfile( ... ProfileNoisyDiscrete, ... d_type_fixed_share={('abc', 0.4, 0.01): Fraction(2, 11)}, ... left_ranking='abc', right_ranking='cab', ... noise=0.01) >>> profile = xyy_to_profile(x=Fraction(4, 9), y1=0.4, y2=0.9) >>> print(profile) <abc 0.4 ± 0.01: 7/11, cab 0.9 ± 0.01: 4/11> (Condorcet winner: a)