Introduction

The density function of the Poisson distribution:

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

Parameters:

  • rate_par is $\lambda$. Note: this need not be an integer.

Density


Definition:

 
template<typename T>
statslib_constexpr
return_t<T> dpois(const uint_t x, const T rate_par, const bool log_form = false);

Computes the density function.


Examples:

// parameters
double rate = 14.0;

// standard input
double dens_val = stats::dpois(10,rate);
double log_dens_val = stats::dpois(10,rate,true);

// Armadillo input
arma::mat X(10,1);
X.fill(10);

arma::mat dens_vals_mat = stats::dpois(X,rate);
arma::mat log_dens_vals_mat = stats::dpois(X,rate,true);

Probability


Definition:

 
template<typename T>
statslib_constexpr
return_t<T> ppois(const uint_t x, const T rate_par, const bool log_form = false);

Computes the cumulative distribution function (CDF).


Examples:

// parameters
double rate = 14.0;

// standard input
double prob_val = stats::ppois(15,rate);
double log_prob_val = stats::ppois(15,rate,true);

// Armadillo input
arma::mat X(10,1);
X.fill(15);

arma::mat prob_vals_mat = stats::ppois(X,rate);
arma::mat log_prob_vals_mat = stats::ppois(X,rate,true);

Quantile


Definition:

 
template<typename Ta, typename Tb, typename Tc = uint_t>
statslib_constexpr
Tc qpois(const Ta p, const Tb rate_par);

Computes the quantile function.


Examples:

// parameters
double rate = 14.0;

// standard input
double quant_val = stats::qpois(0.7,rate);

// Armadillo input
arma::mat X(10,1);
X.fill(0.7);

arma::mat quant_vals_mat = stats::qpois(X,rate);

Random Sampling


Definition:

 
// random engine seeding
template<typename T>
statslib_inline
return_t<T> rpois(const T rate_par, rand_engine_t& engine);

// seeding values
template<typename T>
statslib_inline
return_t<T> rpois(const T rate_par, uint_t seed_val = std::random_device{}());

// matrix output
template<typename mT, typename eT>
statslib_inline
mT rpois(const uint_t n, const uint_t k, const eT rate_par);

Generates pseudo-random draws.


Examples:

// parameters
double rate = 14.0;

// standard input
double rand_val = stats::rpois(rate);

// Armadillo output: 10 x 1 matrix
arma::mat rand_mat = stats::rpois<arma::mat>(10,1,rate);