Boost: Poisson distribution#
The following functions return the pmf, cdf, qtf or boost class of the Poisson distribution with mean \(mu\) and the support interval \((0,+\infty)\), and \(0 \le q \le 1\).
See also Wikipedia [1281], MathWorld [908], BoostMath [90], Ehrhardt [309] (3.9.26).
- Ctx.poisson_pmf(k, mu)#
where
CtxisMath53orCtxBoost.Returns \(\text{pmf}(x)\), the value of the probability mass function (Pmf) of the Poisson distribution:
\[\text{pmf}(x) = \frac{\mu^k}{k!} e^{-\mu}.\]The following example shows both forms of the syntax:
>>> from mpfebnet import * >>> a = 0; b = 1; t = 0.3; x = 0.6; >>> print ("PoissonPdf(x, a, b): ", PoissonPdf(x, a, b)) >>> print ("dist_poisson(a, b).pdf(x): ", dist_poisson(a, b).pdf(x)) 6.3563523462564525615615615614561356E+00
- Ctx.poisson_cdf(k, mu)#
where
CtxisMath53orCtxBoost.Returns \(\text{cdf}(x)\), the value of the cumulative distribution function (Cdf) of the Poisson distribution:
\[\text{cdf}(x) = e^{-\mu} \sum_{i=0}^k \frac{\mu^i}{i!} = Q(1+k,\mu).\]Here \(Q(\cdot)\) denotes the upper regularized incomplete gamma function (RealGammaQ).
The following example shows both forms of the syntax:
>>> from mpfebnet import * >>> a = 0; b = 1; t = 0.3; x = 0.6; >>> print ("PoissonCdf(x, a, b): ", PoissonCdf(x, a, b)) >>> print ("dist_poisson(a, b).cdf(x): ", dist_poisson(a, b).cdf(x)) 6.3563523462564525615615615614561356E+00
- Ctx.poisson_qtf(q, mu)#
where
CtxisMath53orCtxBoost.Returns \(\text{qtf}(q)\), the value of the quantile function (Qtf) of the Poisson distribution:
\[\text{qtf}(q) = \mathrm{gammaq\_inva}(\mu, p) - 1.\]Here \(\mathrm{gammaq\_inva}(\cdot)\) denotes the inverse (on parameter \(a\)) of the real upper normalised incomplete gamma function (RealGammaQInva).
The following example shows both forms of the syntax:
>>> from mpfebnet import * >>> a = 0; b = 1; t = 0.3; q = 0.6; >>> print ("PoissonQtf(q, a, b): ", PoissonQtf(q, a, b)) >>> print ("dist_poisson(a, b).qtf(q): ", dist_poisson(a, b).qtf(q)) 6.3563523462564525615615615614561356E+00
- class ctx.dist_poisson(lambda1)#
where
ctxisfpm,mpm,ipm,dec,gmporapm.The Poisson distribution is a discrete (lattice) probability distribution with mean \(mu\) and the support interval \((0,+\infty)\). See also Wikipedia [1281], MathWorld [908], BoostMath [90], and Witkovský [1644], R (Statistical System) [560].
See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.pdtr.html#scipy.special.pdtr
See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.pdtrc.html#scipy.special.pdtrc
See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.pdtri.html#scipy.special.pdtri
See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.pdtrik.html#scipy.special.pdtrik
- dist_poisson.pmf(x)#
Returns \(\text{pmf}_X(x)\), the probability mass function (pmf) of a random variable \(X\), following a Poisson distribution:
\[\text{pmf}_X(x) = \frac{\lambda_1^k}{k!} e^{-\lambda_1}.\]>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; x = 3; >>> print ("pmf: ", poisson(mu, sigma).pmf(x)) 6.3563523462564525615615615614561356E-20
- dist_poisson.cdf(x)#
Returns \(\text{cdf}_X(x)\), the cumulative distribution function (cdf) of a random variable \(X\), following a Poisson distribution:
\[\text{cdf}_X(x) = e^{-\lambda_1} \sum_{i=0}^k \frac{\lambda_1^i}{i!} = Q(1+k,\lambda_1).\]Here \(Q(\cdot)\) denotes the upper regularized incomplete gamma functions.
>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; x = 3; >>> print ("cdf: ", poisson(mu, sigma).pmf(x)) 6.3563523462564525615615615614561356E-20
- dist_poisson.sf(x)#
Returns \(\text{sf}_X(x)\), the survival function (sf) of a random variable \(X\), following a Poisson distribution:
\[\text{sf}_X(x) = 1 - e^{-\lambda_1} \sum_{i=0}^k \frac{\lambda_1^i}{i!} = P(1+k,\lambda_1).\]Here \(P(\cdot)\) denotes the lower regularized incomplete gamma functions.
>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; x = 3; >>> print (" sf: ", poisson(mu, sigma).pmf(x)) sf: 6.3563523462564525615615615614561356E-20
- dist_poisson.qtf(q)#
Returns \(\text{qtf}_X(x)\), the quantile function (qtf) of a random variable \(X\), following a Poisson distribution.
\[\text{qtf}_X(q) = \mathrm{gamma_q\_inva}(\lambda_1, p) - 1.\]Here \(\mathrm{gamma_q\_inva}(\cdot)\) denotes the inverse (on parameter \(a\)) of the real normalised incomplete gamma function.
>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; q = 0.3; >>> print ("qtf: ", poisson(mu, sigma).qtf(q)) qtf: 6.3563523462564525615615615614561356E+00
- dist_poisson.isf(q)#
Returns \(\text{isf}_X(q)\), the inverse survival function (isf) of a random variable \(X\), following a Poisson distribution:
\[\text{isf}_X(q) = \mathrm{gamma_p\_inva}(\lambda_1, q) - 1.\]Here \(\mathrm{gamma_p\_inva}(\cdot)\) denotes the inverse (on parameter \(a\)) of the real normalised complementary incomplete gamma function.
>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; q = 0.3; >>> print ("isf: ", poisson(mu, sigma).isf(q)) 6.3563523462564525615615615614561356E+00
- dist_poisson.g_x(t)#
Returns \(G_X(t)\), the probability generating function of a random variable \(X\), following a Poisson distribution:
\[G_X(t) = \exp( \lambda(t -1)).\]>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; t = 0.3; >>> print ("c_x: ", poisson(mu, sigma).c_x(t)) 6.3563523462564525615615615614561356E+00
- dist_poisson.c_x(t)#
Returns \(C_X(t)\), the characteristic function of a random variable \(X\), following a Poisson distribution:
\[C_X(t) = \exp( \lambda(e^{it} -1)).\]>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; t = 0.3; >>> print ("c_x: ", poisson(mu, sigma).c_x(t)) 6.3563523462564525615615615614561356E+00
- dist_poisson.m_x(t)#
Returns \(M_X(t)\), the moment generating function of a random variable \(X\), following a Poisson distribution:
\[M_X(t) = \exp( \lambda(e^{t} -1)).\]\[L_X(t) = \exp( \lambda(e^{-t} -1)).\]>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; t = 0.3; >>> print ("m_x: ", poisson(mu, sigma).c_x(t)) 6.3563523462564525615615615614561356E+00
- dist_poisson.k_x(t, k=0)#
Returns \(K_X(t)\), the cumulant generating function of a random variable \(X\), following a Poisson distribution:
\[K_X(t) = \lambda(e^t -1).\]>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; t = 0.3; k = 6; >>> print ("c_x: ", poisson(mu, sigma).k_x(t, k)) 6.3563523462564525615615615614561356E+00
- dist_poisson.moments(k)#
Returns the first \(j\) moments, \(\mu_j, j = 1 \ldots k\), of a random variable \(X\), following a Poisson distribution (Wikipedia). The moments are calculated from the cumulants.
>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; k = 6; >>> print ("saddlepoint: ", poisson(mu, sigma).moments(k)) 6.3563523462564525615615615614561356E+00
- dist_poisson.cumulants(k)#
Returns the first \(j\) cumulants, \(\kappa_j, j = 1 \ldots k\), of a random variable \(X\), following a Poisson distribution:
\[\kappa_r = \lambda, \quad r = 1, 2, ...\]>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; k = 6; >>> print ("saddlepoint: ", poisson(mu, sigma).cumulants(k)) 6.3563523462564525615615615614561356E+00
Approximations
- ctx.poisson_ecf(x, f, rho, omega)#
where
ctxisipm,dec,mpm, orgmp.Calculates the Edgeworth approximation to the pdf, cdf and sf.
- ctx.poisson_ecf_inv(x, f, rho, omega)#
where
ctxisipm,dec,mpm, orgmp.Calculates the Cornish-Fisher approximation to the qtf and isf.
- ctx.poisson_spa(x, n, results='c')#
where
ctxisfpm,mpm,ipm,dec,gmporapm.Calculates the Luggannini-Rice saddlepoint approximation of the pdf, cdf and sf.
The solution \(\hat{s}(x)\) of the saddlepoint equation \(K_X^{(1)}(\hat{s}(x))=x\), of a random variable \(X\), following a Poisson distribution is given by:
\[\hat{s}(x)= \log ( k / \lambda).\]
- ctx.poisson_spa_inv(x, n, results='qtf')#
where
ctxisfpm,mpm,ipm,dec,gmporapm.Calculates the inverse Jensen saddlepoint approximation of the qtf and isf.