# TauVector¶

[1]:

from fractions import Fraction
import poisson_approval as pa


## A Tau-Vector and its Basic Properties¶

The most usual way to define a tau-vector (ballot shares) is to deduce it from applying a given strategy in a given profile, like in the tutorial on ProfileNoisyDiscrete. That being said, a tau-vector can also be defined directly:

[2]:

tau = pa.TauVector({'a': Fraction(1, 10), 'ab': Fraction(3, 5), 'c': Fraction(3, 10)})


Share of the ballot $$ab$$:

[3]:

tau.ab

[3]:

Fraction(3, 5)


Scores:

[4]:

tau.scores

[4]:

{a: 7/10, b: 3/5, c: 3/10}


Winners:

[5]:

tau.winners

[5]:

{'a'}


## Events: Duos, Pivots and Trios¶

An Event provides the asymptotic development of the limit probability when the expected number of voters $$n$$ tend to infinity, as well as the offsets for each type of ballot.

Duo between $$a$$ and $$b$$:

($$a$$ and $$b$$ have the same score, but not necessarily higher than $$c$$.)

[6]:

tau.duo_ab

[6]:

<asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1>


Access the asymptotic development and the offsets:

[7]:

tau.duo_ab.asymptotic

[7]:

exp(- 0.1 n + o(1))

[8]:

tau.duo_ab.phi_a

[8]:

0.0


Pivots between $$a$$ and $$b$$:

(For the definition of each variant, cf. Reference section.)

[9]:

tau.pivot_weak_ab

[9]:

<asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1>

[10]:

tau.pivot_strict_ab

[10]:

<asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1>

[11]:

tau.pivot_tij_abc

[11]:

<asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1>

[12]:

tau.pivot_tjk_abc

[12]:

<asymptotic = exp(- inf)>


Trios:

(For the definition of each variant, cf. Reference section.)

[13]:

tau.trio

[13]:

<asymptotic = exp(- 0.151472 n - 0.5 log n - 0.836813 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107>

[14]:

tau.trio_1t_a

[14]:

<asymptotic = exp(- inf)>

[15]:

tau.trio_2t_ab

[15]:

<asymptotic = exp(- 0.151472 n - 0.5 log n - 1.18339 + o(1)), phi_a = 0, phi_c = 1.41421, phi_ab = 0.707107>


Print all the weak pivots:

[16]:

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>


Print all the pivots:

[17]:

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>


## Best Responses¶

The focus of a tau-vector is defined as:

• Direct: the three weak pivots have distinct magnitudes.
• Forward-Focused: the two lowest magnitudes are equal, the highest one is different.
• Backward-Focused: the two highest magnitudes are equal, the lowest one is different.
• Unfocused: the three magnitudes are equal.
[18]:

tau.focus

[18]:

Focus.DIRECT


Best response for each ranking:

[19]:

tau.d_ranking_best_response

[19]:

{abc: <ballot = a, threshold_utility = 1, justification = Asymptotic method>, acb: <ballot = a, threshold_utility = 1, justification = Asymptotic method>, bac: <ballot = ab, threshold_utility = 0, justification = Asymptotic method>, bca: <ballot = bc, threshold_utility = 0, justification = Asymptotic method>, cab: <ballot = c, threshold_utility = 1, justification = Asymptotic method>, cba: <ballot = bc, threshold_utility = 0, justification = Asymptotic method>}


Characteristics of the best response for voters with ranking $$abc$$:

[20]:

tau.d_ranking_best_response['abc']

[20]:

<ballot = a, threshold_utility = 1, justification = Asymptotic method>

[21]:

tau.d_ranking_best_response['abc'].ballot

[21]:

'a'

[22]:

tau.d_ranking_best_response['abc'].threshold_utility

[22]:

1.0

[23]:

tau.d_ranking_best_response['abc'].justification

[23]:

'Asymptotic method'

[24]:

tau.d_ranking_best_response['abc'].pivot_tij

[24]:

<asymptotic = exp(- 0.1 n + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1>


## Strategy with Attached Profile and Implicit Tau¶

As mentioned in the tutorial on ProfileNoisyDiscrete, you can define a strategy with an attached profile:

[25]:

profile = pa.ProfileNoisyDiscrete({
('abc', 0.4, 0.01): Fraction(1, 10),
('bac', 0.2, 0.01): Fraction(6, 10),
('cab', 0.7, 0.01): Fraction(3, 10)
})
strategy = pa.StrategyOrdinal({'abc': 'a', 'bac': 'ab', 'cab': 'c'}, profile=profile)


This defines a tau vector:

[26]:

strategy.tau

[26]:

<a: 1/10, ab: 3/5, c: 3/10> ==> a


In that case, the strategy has shortcuts for all the properties of the tau vector. Thus for example, instead of writing:

[27]:

strategy.tau.scores

[27]:

{a: 7/10, b: 3/5, c: 3/10}


You can simply write:

[28]:

strategy.scores

[28]:

{a: 7/10, b: 3/5, c: 3/10}


[29]:

strategy.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>


You can write:

[30]:

strategy.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>


## Symbolic Computation¶

Up to now, all the computations we made were numeric. When defining a profile or a tau-vector, you can use the option symbolic=True. In that case, all computations will be symbolic if possible. Note, however, that this option is much slower than numeric computation.

[31]:

profile = pa.ProfileNoisyDiscrete({
('abc', 0.4, 0.01): Fraction(1, 10),
('bac', 0.2, 0.01): Fraction(6, 10),
('cab', 0.7, 0.01): Fraction(3, 10)
}, symbolic=True)
strategy = pa.StrategyOrdinal({'abc': 'a', 'bac': 'ab', 'cab': 'c'}, profile=profile)

[32]:

strategy.print_weak_pivots()

pivot_weak_ab:  <asymptotic = exp(- n/10 + o(1)), phi_a = 0, phi_c = 1, phi_ab = 1>
pivot_weak_ac:  <asymptotic = exp(n*(-1 + sqrt(21)/5) - log(n)/2 - log(2*sqrt(21)*pi/5)/2 + o(1)), phi_a = sqrt(21)/7, phi_c = sqrt(21)/3, phi_ab = sqrt(21)/7>
pivot_weak_bc:  <asymptotic = exp(n*(-1 + 3*sqrt(2)/5) - log(n)/2 - log(6*sqrt(2)*pi/5)/2 + o(1)), phi_a = 0, phi_c = sqrt(2), phi_ab = sqrt(2)/2>
trio:  <asymptotic = exp(n*(-1 + 3*sqrt(2)/5) - log(n)/2 - log(6*sqrt(2)*pi/5)/2 + o(1)), phi_a = 0, phi_c = sqrt(2), phi_ab = sqrt(2)/2>