SimplexToProfile

class poisson_approval.SimplexToProfile(cls, right_type, top_type, left_type, d_type_fixed_share=None, **kwargs)[source]

Map a point of the simplex to a profile (for ternary plots).

Parameters
  • cls (class) – ProfileDiscrete, ProfileHistogram, ProfileNoisyDiscrete, ProfileOrdinal or ProfileTwelve.

  • right_type (object) – A type that is suitable for the kind of profile used.

  • top_type (object) – A type that is suitable for the kind of profile used.

  • left_type (object) – A type that is suitable for the kind of profile used.

  • 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

A SimplexToProfile object is a callable. When called, it takes three parameters right, top, left, numbers that represent a point in the simplex. 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_type, right_type and top_type, in respective proportions that are given by the input tuple (right, top, left).

Examples

Typical usage:

>>> simplex_to_profile = SimplexToProfile(
...     ProfileNoisyDiscrete,
...     left_type=('abc', 0.5, 0.01), right_type=('bac', 0.5, 0.01), top_type='c>a~b',
...     d_type_fixed_share={('abc', 0.1, 0.01): Fraction(1, 10), ('abc', 0.9, 0.01): Fraction(2, 10)})
>>> profile = simplex_to_profile(left=Fraction(11, 80), top=Fraction(52, 80), right=Fraction(17, 80))
>>> print(profile)
<abc 0.1 ± 0.01: 1/10, abc 0.5 ± 0.01: 77/800, abc 0.9 ± 0.01: 1/5, bac 0.5 ± 0.01: 119/800, c>a~b: 91/200> (Condorcet winner: a)

The types with variable share and fixed share may overlap:

>>> simplex_to_profile = SimplexToProfile(
...     ProfileNoisyDiscrete,
...     left_type=('abc', 0.5, 0.01), right_type=('bac', 0.5, 0.01), top_type='c>a~b',
...     d_type_fixed_share={('abc', 0.5, 0.01): Fraction(93, 100)})
>>> profile = simplex_to_profile(left=Fraction(4, 7), top=Fraction(2, 7), right=Fraction(1, 7))
>>> print(profile)
<abc 0.5 ± 0.01: 97/100, bac 0.5 ± 0.01: 1/100, c>a~b: 1/50> (Condorcet winner: a)