Asymptotic

class poisson_approval.Asymptotic(mu, nu, xi, symbolic=False)[source]

An asymptotic development of the form \(\exp(\mu n + \nu \log n + \xi + o(1))\).

Parameters
  • mu (Number, sp.nan, np.nan, - sp.oo or - np.inf) – Coefficient of the term in n (called “magnitude”).

  • nu (Number, sp.nan, np.nan, - sp.oo or - np.inf) – Coefficient of the term in log n.

  • xi (Number, sp.nan, np.nan, - sp.oo or - np.inf) – Constant coefficient.

  • symbolic (bool) – Whether the computations are symbolic or numeric.

μ

Alias for mu.

Type

Number, sp.nan, np.nan, - sp.oo or - np.inf

ν

Alias for nu.

Type

Number, sp.nan, np.nan, - sp.oo or - np.inf

ξ

Alias for xi.

Type

Number, sp.nan, np.nan, - sp.oo or - np.inf

Notes

If a coefficient is sp.nan or np.nan, it means that it is not known. In contrast, a coefficient 0 means that there is no corresponding term in the asymptotic development.

If (and only if) the event is impossible, then mu = nu = xi = - inf. It is possible to use either - sp.oo or - np.inf.

Examples

>>> import math
>>> asymptotic = Asymptotic(mu=-1 / 9, nu=-1 / 2, xi=-1 / 2 * math.log(8 * math.pi / 9))
>>> print(asymptotic)
exp(- 0.111111 n - 0.5 log n - 0.513473 + o(1))
>>> asymptotic.mu
-0.1111111111111111
>>> asymptotic.nu
-0.5
>>> asymptotic.xi
-0.5134734250965083
property limit

Limit when n tends to infinity.

Examples

>>> import numpy as np
>>> Asymptotic(mu=-1, nu=0, xi=0).limit
0
>>> Asymptotic(mu=1, nu=0, xi=0).limit
inf
>>> Asymptotic(mu=-1, nu=np.nan, xi=np.nan).limit
0
>>> Asymptotic(mu=0, nu=-1, xi=np.nan).limit
0

nan means that the limit is unknown:

>>> Asymptotic(mu=0, nu=0, xi=np.nan).limit
nan
Type

Number, nan or infinity

look_equal(other, *args, **kwargs)[source]

Test if two asymptotic developments can reasonably be considered as equal.

Parameters
  • other (Asymptotic) –

  • *args – Cf. math.isclose.

  • **kwargs – Cf. math.isclose.

Returns

True if this asymptotic development can reasonably be considered equal to other. Cf. ComputationEngine.look_equal().

Return type

bool

Examples

>>> Asymptotic(mu=1, nu=2, xi=3).look_equal(
...     Asymptotic(mu=0.999999999999, nu=2.00000000001, xi=3))
True
classmethod poisson_eq(tau_1, tau_2, symbolic=False)[source]

Asymptotic development of P(X_1 = X_2), where X_i ~ Poison(tau_i * n).

Parameters
  • tau_1 (Number) – The parameter of the Poisson distribution of X_i is tau_i * n, where n tends to infinity.

  • tau_2 (Number) – The parameter of the Poisson distribution of X_i is tau_i * n, where n tends to infinity.

  • symbolic (bool) – Whether the computations are symbolic or numeric.

Returns

The asymptotic development of P(X_1 = X_2), where X_i ~ Poison(tau_i * n).

Return type

Asymptotic

Examples

>>> from math import pi, log
>>> print(Asymptotic.poisson_eq(tau_1=0, tau_2=0))
exp(o(1))
>>> print(Asymptotic.poisson_eq(tau_1=1/10, tau_2=0))
exp(- 0.1 n + o(1))
>>> Asymptotic.poisson_eq(tau_1=1/10, tau_2=9/10).look_equal(
...     Asymptotic(mu=-.4, nu=-.5, xi=-.5 * log(1.2 * pi)))
True
classmethod poisson_ge(tau_1, tau_2, symbolic=False)[source]

Asymptotic development of P(X_1 >= X_2), where X_i ~ Poison(tau_i * n).

Parameters
  • tau_1 (Number) – The parameter of the Poisson distribution of X_i is tau_i * n, where n tends to infinity.

  • tau_2 (Number) – The parameter of the Poisson distribution of X_i is tau_i * n, where n tends to infinity.

  • symbolic (bool) – Whether the computations are symbolic or numeric.

Returns

The asymptotic development of P(X_1 >= X_2), where X_i ~ Poison(tau_i * n).

Return type

Asymptotic

Examples

>>> from math import log
>>> print(Asymptotic.poisson_ge(tau_1=0, tau_2=0))
exp(o(1))
>>> print(Asymptotic.poisson_ge(tau_1=0, tau_2=1/10))
exp(- 0.1 n + o(1))
>>> print(Asymptotic.poisson_ge(tau_1=1/10, tau_2=0))
exp(o(1))
>>> Asymptotic.poisson_ge(tau_1=9/10, tau_2=1/10).look_equal(
...     Asymptotic(mu=0, nu=0, xi=0))
True
>>> Asymptotic.poisson_ge(tau_1=3/10, tau_2=3/10).look_equal(
...     Asymptotic(mu=0, nu=0, xi=-log(2)))
True
>>> asymptotic = Asymptotic.poisson_ge(tau_1=1/10, tau_2=9/10)
>>> asymptotic_eq = Asymptotic.poisson_eq(tau_1=1/10, tau_2=9/10)
>>> asymptotic.look_equal(
...     Asymptotic(mu=asymptotic_eq.mu, nu=asymptotic_eq.nu, xi=asymptotic_eq.xi + log(3/2)))
True
classmethod poisson_gt(tau_1, tau_2, symbolic=False)[source]

Asymptotic development of P(X_1 > X_2), where X_i ~ Poison(tau_i * n).

Parameters
  • tau_1 (Number) – The parameter of the Poisson distribution of X_i is tau_i * n, where n tends to infinity.

  • tau_2 (Number) – The parameter of the Poisson distribution of X_i is tau_i * n, where n tends to infinity.

  • symbolic (bool) – Whether the computations are symbolic or numeric.

Returns

The asymptotic development of P(X_1 > X_2), where X_i ~ Poison(tau_i * n).

Return type

Asymptotic

Examples

>>> from math import log
>>> print(Asymptotic.poisson_gt(tau_1=0, tau_2=0))
exp(- inf)
>>> print(Asymptotic.poisson_gt(tau_1=0, tau_2=1/10))
exp(- inf)
>>> print(Asymptotic.poisson_gt(tau_1=1/10, tau_2=0))
exp(o(1))
>>> Asymptotic.poisson_gt(tau_1=9/10, tau_2=1/10).look_equal(
...     Asymptotic(mu=0, nu=0, xi=0))
True
>>> Asymptotic.poisson_gt(tau_1=3/10, tau_2=3/10).look_equal(
...     Asymptotic(mu=0, nu=0, xi=-log(2)))
True
>>> asymptotic = Asymptotic.poisson_gt(tau_1=1/10, tau_2=9/10)
>>> asymptotic_eq = Asymptotic.poisson_eq(tau_1=1/10, tau_2=9/10)
>>> asymptotic.look_equal(
...     Asymptotic(mu=asymptotic_eq.mu, nu=asymptotic_eq.nu, xi=asymptotic_eq.xi - log(2)))
True
classmethod poisson_gt_one_more(tau_1, tau_2, symbolic=False)[source]

Asymptotic development of P(X_1 > X_2 + 1), where X_i ~ Poison(tau_i * n).

Parameters
  • tau_1 (Number) – The parameter of the Poisson distribution of X_i is tau_i * n, where n tends to infinity.

  • tau_2 (Number) – The parameter of the Poisson distribution of X_i is tau_i * n, where n tends to infinity.

  • symbolic (bool) – Whether the computations are symbolic or numeric.

Returns

The asymptotic development of P(X_1 > X_2 + 1), where X_i ~ Poison(tau_i * n).

Return type

Asymptotic

Examples

>>> from math import log
>>> print(Asymptotic.poisson_gt_one_more(tau_1=0, tau_2=0))
exp(- inf)
>>> print(Asymptotic.poisson_gt_one_more(tau_1=0, tau_2=1/10))
exp(- inf)
>>> print(Asymptotic.poisson_gt_one_more(tau_1=1/10, tau_2=0))
exp(o(1))
>>> Asymptotic.poisson_gt_one_more(tau_1=9/10, tau_2=1/10).look_equal(
...     Asymptotic(mu=0, nu=0, xi=0))
True
>>> Asymptotic.poisson_gt_one_more(tau_1=3/10, tau_2=3/10).look_equal(
...     Asymptotic(mu=0, nu=0, xi=-log(2)))
True
>>> asymptotic = Asymptotic.poisson_gt_one_more(tau_1=1/10, tau_2=9/10)
>>> asymptotic_eq = Asymptotic.poisson_eq(tau_1=1/10, tau_2=9/10)
>>> asymptotic.look_equal(
...     Asymptotic(mu=asymptotic_eq.mu, nu=asymptotic_eq.nu, xi=asymptotic_eq.xi - log(6)))
True
classmethod poisson_one_more(tau_1, tau_2, symbolic=False)[source]

Asymptotic development of P(X_1 = X_2 + 1), where X_i ~ Poison(tau_i * n).

Parameters
  • tau_1 (Number) – The parameter of the Poisson distribution of X_i is tau_i * n, where n tends to infinity.

  • tau_2 (Number) – The parameter of the Poisson distribution of X_i is tau_i * n, where n tends to infinity.

  • symbolic (bool) – Whether the computations are symbolic or numeric.

Returns

The asymptotic development of P(X_1 = X_2 + 1), where X_i ~ Poison(tau_i * n).

Return type

Asymptotic

Examples

>>> from math import pi, log
>>> print(Asymptotic.poisson_one_more(tau_1=0, tau_2=1/10))
exp(- inf)
>>> print(Asymptotic.poisson_one_more(tau_1=1/10, tau_2=0))
exp(- 0.1 n + log n - 2.30259 + o(1))
classmethod poisson_value(tau, k, symbolic=False)[source]

Asymptotic development of P(X = k), where X ~ Poison(tau * n).

Parameters
  • tau (Number) – The parameter of the Poisson distribution is tau * n, where n tends to infinity.

  • k (int) – The desired value in P(X = k).

  • symbolic (bool) – Whether the computations are symbolic or numeric.

Returns

The asymptotic development of P(X = k), where X ~ Poison(tau * n).

Return type

Asymptotic

Examples

>>> print(Asymptotic.poisson_value(tau=0, k=0))
exp(o(1))
>>> print(Asymptotic.poisson_value(tau=0, k=1))
exp(- inf)
>>> print(Asymptotic.poisson_value(tau=1, k=1))
exp(- n + log n + o(1))
>>> from math import log
>>> Asymptotic.poisson_value(tau=2, k=3).look_equal(
...     Asymptotic(mu=-2, nu=3, xi=3 * log(2) - log(6)))
True
classmethod poisson_x1_eq_x2_plus_k(tau_1, tau_2, k, symbolic=False)[source]

Asymptotic development of P(X_1 = X_2 + k), where X_i ~ Poison(tau_i * n).

Parameters
  • tau_1 (Number) – The parameter of the Poisson distribution of X_i is tau_i * n, where n tends to infinity.

  • tau_2 (Number) – The parameter of the Poisson distribution of X_i is tau_i * n, where n tends to infinity.

  • k (int) – The desired value in P(X_1 = X_2 + k).

  • symbolic (bool) – Whether the computations are symbolic or numeric.

Returns

The asymptotic development of P(X_1 = X_2 + k), where X_i ~ Poison(tau_i * n).

Return type

Asymptotic

Examples

>>> from math import log, pi, sqrt
>>> print(Asymptotic.poisson_x1_eq_x2_plus_k(tau_1=0, tau_2=1, k=0))
exp(- n + o(1))
>>> print(Asymptotic.poisson_x1_eq_x2_plus_k(tau_1=0, tau_2=1, k=1))
exp(- inf)
>>> print(Asymptotic.poisson_x1_eq_x2_plus_k(tau_1=1, tau_2=0, k=1))
exp(- n + log n + o(1))
>>> Asymptotic.poisson_x1_eq_x2_plus_k(tau_1=2, tau_2=0, k=3).look_equal(
...     Asymptotic(mu=-2, nu=3, xi=3 * log(2) - log(6)))
True
>>> Asymptotic.poisson_x1_eq_x2_plus_k(tau_1=1, tau_2=1, k=0).look_equal(
...     Asymptotic(mu=0, nu=- 1 / 2, xi=- 1 / 2 * log(4 * pi)))
True
>>> Asymptotic.poisson_x1_eq_x2_plus_k(tau_1=1, tau_2=2, k=3).look_equal(
...     Asymptotic(mu=- (1 - sqrt(2)) ** 2, nu=- 1 / 2, xi=- 1 / 2 * log(32 * pi * sqrt(2))))
True
classmethod poisson_x1_ge_x2_plus_k(tau_1, tau_2, k, symbolic=False)[source]

Asymptotic development of P(X_1 >= X_2 + k), where X_i ~ Poison(tau_i * n).

Parameters
  • tau_1 (Number) – The parameter of the Poisson distribution of X_i is tau_i * n, where n tends to infinity.

  • tau_2 (Number) – The parameter of the Poisson distribution of X_i is tau_i * n, where n tends to infinity.

  • k (int) – The desired value in P(X_1 >= X_2 + k).

  • symbolic (bool) – Whether the computations are symbolic or numeric.

Returns

The asymptotic development of P(X_1 >= X_2 + k), where X_i ~ Poison(tau_i * n).

Return type

Asymptotic

Examples

>>> from math import log, sqrt, pi
>>> print(Asymptotic.poisson_x1_ge_x2_plus_k(tau_1=0, tau_2=1, k=0))
exp(- n + o(1))
>>> print(Asymptotic.poisson_x1_ge_x2_plus_k(tau_1=0, tau_2=1, k=1))
exp(- inf)
>>> print(Asymptotic.poisson_x1_ge_x2_plus_k(tau_1=1, tau_2=0, k=0))
exp(o(1))
>>> Asymptotic.poisson_x1_ge_x2_plus_k(tau_1=1, tau_2=1, k=0).look_equal(
...     Asymptotic(mu=0, nu=0, xi=- log(2)))
True
>>> Asymptotic.poisson_x1_ge_x2_plus_k(tau_1=1, tau_2=2, k=3).look_equal(Asymptotic(
...     mu=- (1 - sqrt(2)) ** 2, nu=- 1 / 2,
...     xi=(- 1 / 2 * log(32 * pi * sqrt(2)) - log(1 - sqrt(1 / 2)))))
True