Tau Vector
- class poisson_approval.TauVector(d_ballot_share: dict, voting_rule='Approval', symbolic=False, normalization_warning: bool = True)[source]
A vector tau (ballot distribution).
- Parameters
d_ballot_share (dict) – Ballot distribution, e.g.
{'a': 0.1, 'ab': 0.6, 'c':0.3}
.voting_rule (str) – The voting rule. Possible values are
APPROVAL
,PLURALITY
andANTI_PLURALITY
.symbolic (bool) – Whether the computations are symbolic or numeric.
normalization_warning (bool) – Whether a warning should be issued if the input distribution is not normalized.
Notes
If the input distribution d_ballot_share is not normalized, the tau vector will be normalized anyway and a warning will be issued (unless normalization_warning is False).
Examples
>>> from fractions import Fraction >>> tau = TauVector({'a': Fraction(1, 10), 'ab': Fraction(3, 5), 'c': Fraction(3, 10)}) >>> tau TauVector({'a': Fraction(1, 10), 'ab': Fraction(3, 5), 'c': Fraction(3, 10)}) >>> print(tau) <a: 1/10, ab: 3/5, c: 3/10> ==> a >>> tau.a Fraction(1, 10) >>> tau.b 0 >>> tau.c Fraction(3, 10) >>> tau.ab Fraction(3, 5) >>> tau.ba # Alternate notation for tau.ab Fraction(3, 5) >>> tau.ac 0 >>> tau.ca # Alternate notation for tau.ac, etc. 0 >>> tau.bc 0 >>> tau.cb 0 >>> tau.duo_ab <asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> >>> tau.duo_ba <asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> >>> tau.duo_ac <asymptotic = exp(- 0.0834849 n - 0.5 log n - 0.87535 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> >>> tau.duo_ca <asymptotic = exp(- 0.0834849 n - 0.5 log n - 0.87535 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> >>> tau.duo_bc <asymptotic = exp(- 0.0514719 n - 0.5 log n - 0.836813 + o(1)), phi_a = 1, phi_c = 1.41421, phi_ab = 0.707107> >>> tau.duo_cb <asymptotic = exp(- 0.0514719 n - 0.5 log n - 0.836813 + o(1)), phi_a = 1, phi_c = 1.41421, phi_ab = 0.707107> >>> tau.pivot_weak_ab <asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> >>> tau.pivot_weak_ba <asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> >>> tau.pivot_weak_ac <asymptotic = exp(- 0.0834849 n - 0.5 log n - 0.87535 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> >>> tau.pivot_weak_ca <asymptotic = exp(- 0.0834849 n - 0.5 log n - 0.87535 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> >>> tau.pivot_weak_bc <asymptotic = exp(- 0.151472 n - 0.5 log n - 0.836813 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> >>> tau.pivot_weak_cb <asymptotic = exp(- 0.151472 n - 0.5 log n - 0.836813 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> >>> tau.pivot_strict_ab <asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> >>> tau.pivot_strict_ba <asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> >>> tau.pivot_strict_ac <asymptotic = exp(- 0.0834849 n - 0.5 log n - 0.87535 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> >>> tau.pivot_strict_ca <asymptotic = exp(- 0.0834849 n - 0.5 log n - 0.87535 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> >>> tau.pivot_strict_bc <asymptotic = exp(- inf)> >>> tau.pivot_strict_cb <asymptotic = exp(- inf)> >>> tau.pivot_tij_abc <asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> >>> tau.pivot_tij_acb <asymptotic = exp(- 0.0834849 n - 0.5 log n - 0.371758 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> >>> tau.pivot_tij_bac <asymptotic = exp(- 0.1 n + log n - 2.30259 + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> >>> tau.pivot_tij_bca <asymptotic = exp(- 0.151472 n - 0.5 log n - 0.302013 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> >>> tau.pivot_tij_cab <asymptotic = exp(- 0.0834849 n - 0.5 log n + 0.0518905 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> >>> tau.pivot_tij_cba <asymptotic = exp(- 0.151472 n - 0.5 log n - 0.836813 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> >>> tau.pivot_tjk_abc <asymptotic = exp(- inf)> >>> tau.pivot_tjk_acb <asymptotic = exp(- inf)> >>> tau.pivot_tjk_bac <asymptotic = exp(- 0.0834849 n - 0.5 log n - 0.371758 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> >>> tau.pivot_tjk_bca <asymptotic = exp(- 0.0834849 n - 0.5 log n + 0.0518905 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> >>> tau.pivot_tjk_cab <asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> >>> tau.pivot_tjk_cba <asymptotic = exp(- 0.1 n + log n - 2.30259 + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> >>> tau.trio <asymptotic = exp(- 0.151472 n - 0.5 log n - 0.836813 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> >>> tau.trio_1t_a <asymptotic = exp(- inf)> >>> tau.trio_1t_b <asymptotic = exp(- 0.151472 n + 0.5 log n - 3.48597 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> >>> tau.trio_1t_c <asymptotic = exp(- 0.151472 n - 0.5 log n - 0.490239 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> >>> tau.trio_2t_ab <asymptotic = exp(- 0.151472 n - 0.5 log n - 1.18339 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> >>> tau.trio_2t_ac <asymptotic = exp(- inf)> >>> tau.trio_2t_bc <asymptotic = exp(- 0.151472 n + 0.5 log n - 3.1394 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> >>> tau.trio_2t_ba <asymptotic = exp(- 0.151472 n - 0.5 log n - 1.18339 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> >>> tau.trio_2t_ca <asymptotic = exp(- inf)> >>> tau.trio_2t_cb <asymptotic = exp(- 0.151472 n + 0.5 log n - 3.1394 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107>
- property a
Share of the ballot
'a'
.- Type
Number
- property ab
Share of the ballot
'ab'
.- Type
Number
- property ac
Share of the ballot
'ac'
.- Type
Number
- property b
Share of the ballot
'b'
.- Type
Number
- property ba
Share of the ballot
'ab'
(alternate notation).- Type
Number
- property bc
Share of the ballot
'bc'
.- Type
Number
- property c
Share of the ballot
'c'
.- Type
Number
- property ca
Share of the ballot
'ac'
(alternate notation).- Type
Number
- property cb
Share of the ballot
'bc'
(alternate notation).- Type
Number
- property d_ranking_best_response
Best response profile.
Key: a ranking (e.g.
'abc'
).Value: a
BestResponse
(whose subclass depends on voting_rule).
Examples
>>> from fractions import Fraction >>> tau = TauVector({'a': Fraction(1, 10), 'ab': Fraction(3, 5), 'c': Fraction(3, 10)}) >>> tau.d_ranking_best_response['abc'] <ballot = a, utility_threshold = 1, justification = Asymptotic method>
- Type
dict
- property focus
Focus of this tau-vector.
This is based on the weak pivots.
Examples
>>> from fractions import Fraction >>> tau = TauVector({'a': Fraction(1, 10), 'ab': Fraction(3, 5), 'c': Fraction(3, 10)}) >>> tau.focus Focus.DIRECT
- Type
- property has_two_consecutive_zeros
bool
Whether the tau-vector has two consecutive holes in the “compass” representation. True iff
self.a == 0 and self.ab == 0
, orself.ab == 0 and self.b == 0
, etc.
- property is_best_response_ordinal
Whether the best responses of all rankings are ordinal (not utility-dependent).
Examples
>>> from fractions import Fraction >>> tau = TauVector({'a': Fraction(1, 10), 'ab': Fraction(3, 5), 'c': Fraction(3, 10)}) >>> tau.is_best_response_ordinal True
- Type
bool
- property is_standardized
Whether the profile is standardized or not. Cf.
standardized_version()
.Examples
>>> from fractions import Fraction >>> tau = TauVector({'a': Fraction(1, 10), 'ab': Fraction(3, 5), 'c': Fraction(3, 10)}) >>> tau.is_standardized False
- isclose(other, *args, **kwargs)[source]
Test near-equality.
- Parameters
other (object) –
*args – Cf.
math.isclose
.**kwargs – Cf.
math.isclose
.
- Returns
isclose – True if this tau-vector is approximately equal to other. Cf.
isclose()
.- Return type
bool
Examples
>>> tau = TauVector({'ab': 0.4, 'b': 0.6}) >>> tau.isclose(TauVector({'ab': 0.4, 'b': 0.59999999999999999999999999})) True
- property pivot_ab_easy_or_tight
True if the pivot ab is easy or tight, False if it is difficult.
- Type
bool
- property pivot_ac_easy_or_tight
True if the pivot ac is easy or tight, False if it is difficult.
- Type
bool
- property pivot_ba_easy_or_tight
Alternate notation for
pivot_ab_easy_or_tight
- Type
bool
- property pivot_bc_easy_or_tight
True if the pivot bc is easy or tight, False if it is difficult.
- Type
bool
- property pivot_ca_easy_or_tight
Alternate notation for
pivot_ac_easy_or_tight
- Type
bool
- property pivot_cb_easy_or_tight
Alternate notation for
pivot_bc_easy_or_tight
- Type
bool
- property pivot_strict_ab
Event where these two candidates have the same score, strictly higher than the remaining candidate.
- Type
- property pivot_strict_ac
Event where these two candidates have the same score, strictly higher than the remaining candidate.
- Type
- property pivot_strict_ba
Event where these two candidates have the same score, strictly higher than the remaining candidate.
- Type
- property pivot_strict_bc
Event where these two candidates have the same score, strictly higher than the remaining candidate.
- Type
- property pivot_strict_ca
Event where these two candidates have the same score, strictly higher than the remaining candidate.
- Type
- property pivot_strict_cb
Event where these two candidates have the same score, strictly higher than the remaining candidate.
- Type
- property pivot_tij_abc
Personalized pivot of type Tij (between the two most-liked candidates).
- Type
- property pivot_tij_acb
Personalized pivot of type Tij (between the two most-liked candidates).
- Type
- property pivot_tij_bac
Personalized pivot of type Tij (between the two most-liked candidates).
- Type
- property pivot_tij_bca
Personalized pivot of type Tij (between the two most-liked candidates).
- Type
- property pivot_tij_cab
Personalized pivot of type Tij (between the two most-liked candidates).
- Type
- property pivot_tij_cba
Personalized pivot of type Tij (between the two most-liked candidates).
- Type
- property pivot_tjk_abc
Personalized pivot of type Tjk (between the two least-liked candidates).
- Type
- property pivot_tjk_acb
Personalized pivot of type Tjk (between the two least-liked candidates).
- Type
- property pivot_tjk_bac
Personalized pivot of type Tjk (between the two least-liked candidates).
- Type
- property pivot_tjk_bca
Personalized pivot of type Tjk (between the two least-liked candidates).
- Type
- property pivot_tjk_cab
Personalized pivot of type Tjk (between the two least-liked candidates).
- Type
- property pivot_tjk_cba
Personalized pivot of type Tjk (between the two least-liked candidates).
- Type
- property pivot_weak_ab
Event where these two candidates have the same score, at least as high as the remaining candidate.
- Type
- property pivot_weak_ac
Event where these two candidates have the same score, at least as high as the remaining candidate.
- Type
- property pivot_weak_ba
Event where these two candidates have the same score, at least as high as the remaining candidate.
- Type
- property pivot_weak_bc
Event where these two candidates have the same score, at least as high as the remaining candidate.
- Type
- property pivot_weak_ca
Event where these two candidates have the same score, at least as high as the remaining candidate.
- Type
- property pivot_weak_cb
Event where these two candidates have the same score, at least as high as the remaining candidate.
- Type
- print_all_pivots()[source]
Print all the pivots.
Examples
>>> from fractions import Fraction >>> tau = TauVector({'a': Fraction(1, 10), 'ab': Fraction(3, 5), 'c': Fraction(3, 10)}) >>> tau.print_all_pivots() pivot_weak_ab: <asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> pivot_weak_ac: <asymptotic = exp(- 0.0834849 n - 0.5 log n - 0.87535 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> pivot_weak_bc: <asymptotic = exp(- 0.151472 n - 0.5 log n - 0.836813 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> pivot_strict_ab: <asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> pivot_strict_ac: <asymptotic = exp(- 0.0834849 n - 0.5 log n - 0.87535 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> pivot_strict_bc: <asymptotic = exp(- inf)> pivot_tij_abc: <asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> pivot_tij_acb: <asymptotic = exp(- 0.0834849 n - 0.5 log n - 0.371758 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> pivot_tij_bac: <asymptotic = exp(- 0.1 n + log n - 2.30259 + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> pivot_tij_bca: <asymptotic = exp(- 0.151472 n - 0.5 log n - 0.302013 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> pivot_tij_cab: <asymptotic = exp(- 0.0834849 n - 0.5 log n + 0.0518905 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> pivot_tij_cba: <asymptotic = exp(- 0.151472 n - 0.5 log n - 0.836813 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> pivot_tjk_abc: <asymptotic = exp(- inf)> pivot_tjk_acb: <asymptotic = exp(- inf)> pivot_tjk_bac: <asymptotic = exp(- 0.0834849 n - 0.5 log n - 0.371758 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> pivot_tjk_bca: <asymptotic = exp(- 0.0834849 n - 0.5 log n + 0.0518905 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> pivot_tjk_cab: <asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> pivot_tjk_cba: <asymptotic = exp(- 0.1 n + log n - 2.30259 + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> trio: <asymptotic = exp(- 0.151472 n - 0.5 log n - 0.836813 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> trio_1t_a: <asymptotic = exp(- inf)> trio_1t_b: <asymptotic = exp(- 0.151472 n + 0.5 log n - 3.48597 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> trio_1t_c: <asymptotic = exp(- 0.151472 n - 0.5 log n - 0.490239 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> trio_2t_ab: <asymptotic = exp(- 0.151472 n - 0.5 log n - 1.18339 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> trio_2t_ac: <asymptotic = exp(- inf)> trio_2t_bc: <asymptotic = exp(- 0.151472 n + 0.5 log n - 3.1394 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> duo_ab: <asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> duo_ac: <asymptotic = exp(- 0.0834849 n - 0.5 log n - 0.87535 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> duo_bc: <asymptotic = exp(- 0.0514719 n - 0.5 log n - 0.836813 + o(1)), phi_a = 1, phi_c = 1.41421, phi_ab = 0.707107>
- print_magnitudes_order()[source]
Print the order of the magnitudes of the weak pivots.
Examples
>>> from fractions import Fraction >>> tau = TauVector({'a': Fraction(1, 10), 'ab': Fraction(3, 5), 'c': Fraction(3, 10)}) >>> tau.print_magnitudes_order() mu_ac > mu_ab > mu_bc
>>> from fractions import Fraction >>> tau = TauVector({'a': Fraction(1, 3), 'b': Fraction(1, 3), 'c': Fraction(1, 3)}) >>> tau.print_magnitudes_order() mu_ab = mu_ac = mu_bc
- print_weak_pivots()[source]
Print the weak pivots (including the 3-way tie).
Examples
>>> from fractions import Fraction >>> tau = TauVector({'a': Fraction(1, 10), 'ab': Fraction(3, 5), 'c': Fraction(3, 10)}) >>> tau.print_weak_pivots() pivot_weak_ab: <asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1> pivot_weak_ac: <asymptotic = exp(- 0.0834849 n - 0.5 log n - 0.87535 + o(1)), phi_a = 0.654654, phi_c = 1.52753, phi_ab = 0.654654> pivot_weak_bc: <asymptotic = exp(- 0.151472 n - 0.5 log n - 0.836813 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107> trio: <asymptotic = exp(- 0.151472 n - 0.5 log n - 0.836813 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107>
- property score_a_in_duo_bc
Score of a in duo bc.
- Type
Number
- property score_a_in_duo_cb
Alternate notation for
score_a_in_duo_bc
.- Type
Number
- property score_ab_in_duo_ab
Common score of a and b in duo ab.
- Type
Number
- property score_ac_in_duo_ac
Common score of a and c in duo ac.
- Type
Number
- property score_b_in_duo_ac
Score of b in duo ac.
- Type
Number
- property score_b_in_duo_ca
Alternate notation for
score_b_in_duo_ac
.- Type
Number
- property score_ba_in_duo_ba
Alternate notation for
score_ab_in_duo_ab
.- Type
Number
- property score_bc_in_duo_bc
Common score of b and c in duo bc.
- Type
Number
- property score_c_in_duo_ab
Score of c in duo ab.
- Type
Number
- property score_c_in_duo_ba
Alternate notation for
score_c_in_duo_ab
.- Type
Number
- property score_ca_in_duo_ca
Alternate notation for
score_ac_in_duo_ac
.- Type
Number
- property score_cb_in_duo_cb
Alternate notation for
score_bc_in_duo_bc
.- Type
Number
- property scores
The scores.
Examples
>>> from fractions import Fraction >>> tau = TauVector({'a': Fraction(1, 10), 'ab': Fraction(3, 5), 'c': Fraction(3, 10)}) >>> tau.scores {'a': Fraction(7, 10), 'b': Fraction(3, 5), 'c': Fraction(3, 10)}
- Type
share of double votes, i.e. votes for two candidates.
Examples
>>> from fractions import Fraction >>> tau = TauVector({'a': Fraction(1, 10), 'ab': Fraction(3, 5), 'c': Fraction(3, 10)}) >>> tau.share_double_votes Fraction(3, 5)
- Type
Number
share of single votes, i.e. votes for one candidate only.
Examples
>>> from fractions import Fraction >>> tau = TauVector({'a': Fraction(1, 10), 'ab': Fraction(3, 5), 'c': Fraction(3, 10)}) >>> tau.share_single_votes Fraction(2, 5)
- Type
Number
- property standardized_version
Standardized version of the profile (makes it unique, up to permutations).
Notes
It returns the same profile, up to a permutation of the candidates. How the permutation is chosen in practice does not really matter: the important point is that the standardized version is the same for all the profile that are identical up to a permutation of the candidates.
Examples
>>> from fractions import Fraction >>> tau = TauVector({'a': Fraction(1, 10), 'ab': Fraction(3, 5), 'c': Fraction(3, 10)}) >>> tau.standardized_version TauVector({'a': Fraction(3, 10), 'b': Fraction(1, 10), 'bc': Fraction(3, 5)})
- property trio_1t_a
Event where this candidate has one vote less than the two others.
- Type
- property trio_1t_b
Event where this candidate has one vote less than the two others.
- Type
- property trio_1t_c
Event where this candidate has one vote less than the two others.
- Type
- property trio_2t_ab
Event where these candidates have one vote less than the remaining candidate.
- Type
- property trio_2t_ac
Event where these candidates have one vote less than the remaining candidate.
- Type
- property trio_2t_ba
Event where these candidates have one vote less than the remaining candidate.
- Type
- property trio_2t_bc
Event where these candidates have one vote less than the remaining candidate.
- Type
- property trio_2t_ca
Event where these candidates have one vote less than the remaining candidate.
- Type
- property trio_2t_cb
Event where these candidates have one vote less than the remaining candidate.
- Type