Poisson Distribution

Table of contents


Density Function

The density function of the Poisson distribution:

\[f(x; \lambda) = \dfrac{\lambda^x \exp(-\lambda)}{x!} \times \mathbf{1}[ x \geq 0]\]

Methods for scalar input, as well as for vector/matrix input, are listed below.

Scalar Input

template<typename T>
constexpr return_t<T> dpois(const llint_t x, const T rate_par, const bool log_form = false) noexcept

Density function of the Poisson distribution.

Example:

stats::dpois(8.0,10.0,false); 

Parameters
  • x – a non-negative integral-valued input.

  • rate_par – the rate parameter, a real-valued input.

  • log_form – return the log-density or the true form.

Returns

the density function evaluated at x.

Vector/Matrix Input

STL Containers

template<typename eT, typename T1, typename rT = common_return_t<eT, T1>>
inline std::vector<rT> dpois(const std::vector<eT> &x, const T1 rate_par, const bool log_form = false)

Density function of the Poisson distribution.

Example:

std::vector<int> x = {2, 3, 4};
stats::dpois(x,4,false);

Parameters
  • x – a standard vector.

  • rate_par – the rate parameter, a real-valued input.

  • log_form – return the log-density or the true form.

Returns

a vector of density function values corresponding to the elements of x.

Armadillo

template<typename eT, typename T1, typename rT = common_return_t<eT, T1>>
inline ArmaMat<rT> dpois(const ArmaMat<eT> &X, const T1 rate_par, const bool log_form = false)

Density function of the Poisson distribution.

Example:

arma::mat X = { {2, 1, 4},
                {3, 5, 6} };
stats::dpois(X,4,false);

Parameters
  • X – a matrix of input values.

  • rate_par – the rate parameter, a real-valued input.

  • log_form – return the log-density or the true form.

Returns

a matrix of density function values corresponding to the elements of X.

Blaze

template<typename eT, typename T1, typename rT = common_return_t<eT, T1>, bool To = blaze::columnMajor>
inline BlazeMat<rT, To> dpois(const BlazeMat<eT, To> &X, const T1 rate_par, const bool log_form = false)

Density function of the Poisson distribution.

Example:

stats::dpois(X,4,false);

Parameters
  • X – a matrix of input values.

  • rate_par – the rate parameter, a real-valued input.

  • log_form – return the log-density or the true form.

Returns

a matrix of density function values corresponding to the elements of X.

Eigen

template<typename eT, typename T1, typename rT = common_return_t<eT, T1>, int iTr = Eigen::Dynamic, int iTc = Eigen::Dynamic>
inline EigenMat<rT, iTr, iTc> dpois(const EigenMat<eT, iTr, iTc> &X, const T1 rate_par, const bool log_form = false)

Density function of the Poisson distribution.

Example:

stats::dpois(X,4,false);

Parameters
  • X – a matrix of input values.

  • rate_par – the rate parameter, a real-valued input.

  • log_form – return the log-density or the true form.

Returns

a matrix of density function values corresponding to the elements of X.


Cumulative Distribution Function

The cumulative distribution function of the Poisson distribution:

\[F(x; \lambda) = \sum_{z \leq x} f(z; \lambda) = \exp(-\lambda) \sum_{z \leq x} \dfrac{\lambda^z}{z!} \times \mathbf{1}[ z \geq 0]\]

Methods for scalar input, as well as for vector/matrix input, are listed below.

Scalar Input

template<typename T>
constexpr return_t<T> ppois(const llint_t x, const T rate_par, const bool log_form = false) noexcept

Distribution function of the Poisson distribution.

Example:

stats::ppois(8.0,10.0,false); 

Parameters
  • x – a non-negative integral-valued input.

  • rate_par – the rate parameter, a real-valued input.

  • log_form – return the log-probability or the true form.

Returns

the cumulative distribution function evaluated at x.

Vector/Matrix Input

STL Containers

template<typename eT, typename T1, typename rT = common_return_t<eT, T1>>
inline std::vector<rT> ppois(const std::vector<eT> &x, const T1 rate_par, const bool log_form = false)

Distribution function of the Poisson distribution.

Example:

std::vector<int> x = {2, 3, 4};
stats::ppois(x,2.0,false);

Parameters
  • x – a standard vector.

  • rate_par – the rate parameter, a real-valued input.

  • log_form – return the log-probability or the true form.

Returns

a vector of CDF values corresponding to the elements of x.

Armadillo

template<typename eT, typename T1, typename rT = common_return_t<eT, T1>>
inline ArmaMat<rT> ppois(const ArmaMat<eT> &X, const T1 rate_par, const bool log_form = false)

Distribution function of the Poisson distribution.

Example:

arma::mat X = { {2, 1, 4},
                {3, 5, 6} };
stats::ppois(X,2.0,false);

Parameters
  • X – a matrix of input values.

  • rate_par – the rate parameter, a real-valued input.

  • log_form – return the log-probability or the true form.

Returns

a matrix of CDF values corresponding to the elements of X.

Blaze

template<typename eT, typename T1, typename rT = common_return_t<eT, T1>, bool To = blaze::columnMajor>
inline BlazeMat<rT, To> ppois(const BlazeMat<eT, To> &X, const T1 rate_par, const bool log_form = false)

Distribution function of the Poisson distribution.

Example:

stats::ppois(X,2.0,false);

Parameters
  • X – a matrix of input values.

  • rate_par – the rate parameter, a real-valued input.

  • log_form – return the log-probability or the true form.

Returns

a matrix of CDF values corresponding to the elements of X.

Eigen

template<typename eT, typename T1, typename rT = common_return_t<eT, T1>, int iTr = Eigen::Dynamic, int iTc = Eigen::Dynamic>
inline EigenMat<rT, iTr, iTc> ppois(const EigenMat<eT, iTr, iTc> &X, const T1 rate_par, const bool log_form = false)

Distribution function of the Poisson distribution.

Example:

stats::ppois(X,2.0,false);

Parameters
  • X – a matrix of input values.

  • rate_par – the rate parameter, a real-valued input.

  • log_form – return the log-probability or the true form.

Returns

a matrix of CDF values corresponding to the elements of X.


Quantile Function

The quantile function of the Poisson distribution:

\[q(p; \lambda) = \inf \left\{ x : p \leq F(x; \lambda) \right\}\]

Methods for scalar input, as well as for vector/matrix input, are listed below.

Scalar Input

template<typename T1, typename T2>
constexpr common_return_t<T1, T2> qpois(const T1 p, const T2 rate_par) noexcept

Quantile function of the Poisson distribution.

Example:

stats::qpois(0.6,10.0); 

Parameters
  • p – a real-valued input.

  • rate_par – the rate parameter, a real-valued input.

Returns

the quantile function evaluated at p.

Vector/Matrix Input

STL Containers

template<typename eT, typename T1, typename rT = common_return_t<eT, T1>>
inline std::vector<rT> qpois(const std::vector<eT> &x, const T1 rate_par)

Quantile function of the Poisson distribution.

Example:

std::vector<double> x = {0.3, 0.5, 0.8};
stats::qpois(x,4);

Parameters
  • x – a standard vector.

  • rate_par – the rate parameter, a real-valued input.

Returns

a vector of quantile values corresponding to the elements of x.

Armadillo

template<typename eT, typename T1, typename rT = common_return_t<eT, T1>>
inline ArmaMat<rT> qpois(const ArmaMat<eT> &X, const T1 rate_par)

Quantile function of the Poisson distribution.

Example:

arma::mat X = { {0.2, 0.7, 0.9},
                {0.1, 0.8, 0.3} };
stats::qpois(X,4);

Parameters
  • X – a matrix of input values.

  • rate_par – the rate parameter, a real-valued input.

Returns

a matrix of quantile values corresponding to the elements of X.

Blaze

template<typename eT, typename T1, typename rT = common_return_t<eT, T1>, bool To = blaze::columnMajor>
inline BlazeMat<rT, To> qpois(const BlazeMat<eT, To> &X, const T1 rate_par)

Quantile function of the Poisson distribution.

Example:

stats::qpois(X,4);

Parameters
  • X – a matrix of input values.

  • rate_par – the rate parameter, a real-valued input.

Returns

a matrix of quantile values corresponding to the elements of X.

Eigen

template<typename eT, typename T1, typename rT = common_return_t<eT, T1>, int iTr = Eigen::Dynamic, int iTc = Eigen::Dynamic>
inline EigenMat<rT, iTr, iTc> qpois(const EigenMat<eT, iTr, iTc> &X, const T1 rate_par)

Quantile function of the Poisson distribution.

Example:

stats::qpois(X,4);

Parameters
  • X – a matrix of input values.

  • rate_par – the rate parameter, a real-valued input.

Returns

a matrix of quantile values corresponding to the elements of X.


Random Sampling

Scalar Output

  1. Random number engines

template<typename T>
inline return_t<T> rpois(const T rate_par, rand_engine_t &engine)

Random sampling function for the Poisson distribution.

Example:

stats::rand_engine_t engine(1776);
stats::rchisq(4,engine);

Parameters
  • rate_par – the rate parameter, a real-valued input.

  • engine – a random engine, passed by reference.

Returns

a pseudo-random draw from the Poisson distribution.

  1. Seed values

template<typename T>
inline return_t<T> rpois(const T rate_par, const ullint_t seed_val = std::random_device{}())

Random sampling function for the Poisson distribution.

Example:

stats::rchisq(4,1776);

Parameters
  • rate_par – the rate parameter, a real-valued input.

  • seed_val – initialize the random engine with a non-negative integral-valued seed.

Returns

a pseudo-random draw from the Poisson distribution.

Vector/Matrix Output

  1. Random number engines

template<typename mT, typename T1>
inline mT rpois(const ullint_t n, const ullint_t k, const T1 rate_par, rand_engine_t &engine)

Random matrix sampling function for the Poisson distribution.

Example:

stats::rand_engine_t engine(1776);
// std::vector
stats::rpois<std::vector<double>>(5,4,4,engine);
// Armadillo matrix
stats::rpois<arma::mat>(5,4,4,engine);
// Blaze dynamic matrix
stats::rpois<blaze::DynamicMatrix<double,blaze::columnMajor>>(5,4,4,engine);
// Eigen dynamic matrix
stats::rpois<Eigen::MatrixXd>(5,4,4,engine);

Note

This function requires template instantiation; acceptable output types include: std::vector, with element type float, double, etc., as well as Armadillo, Blaze, and Eigen dense matrices.

Parameters
  • n – the number of output rows

  • k – the number of output columns

  • rate_par – the rate parameter, a real-valued input.

  • engine – a random engine, passed by reference.

Returns

a matrix of pseudo-random draws from the Poisson distribution.

  1. Seed values

template<typename mT, typename T1>
inline mT rpois(const ullint_t n, const ullint_t k, const T1 rate_par, const ullint_t seed_val = std::random_device{}())

Random matrix sampling function for the Poisson distribution.

Example:

// std::vector
stats::rpois<std::vector<double>>(5,4,4);
// Armadillo matrix
stats::rpois<arma::mat>(5,4,4);
// Blaze dynamic matrix
stats::rpois<blaze::DynamicMatrix<double,blaze::columnMajor>>(5,4,4);
// Eigen dynamic matrix
stats::rpois<Eigen::MatrixXd>(5,4,4);

Note

This function requires template instantiation; acceptable output types include: std::vector, with element type float, double, etc., as well as Armadillo, Blaze, and Eigen dense matrices.

Parameters
  • n – the number of output rows

  • k – the number of output columns

  • rate_par – the rate parameter, a real-valued input.

  • seed_val – initialize the random engine with a non-negative integral-valued seed.

Returns

a matrix of pseudo-random draws from the Poisson distribution.