The density function of the Exponential distribution:
$$ f(x; \lambda) = \lambda \exp(-\lambda x) \times \mathbf{1}[ x \geq 0] $$Parameters:
rate_par
is $\lambda$. Note: this need not be an integer.Definition:
template<typename Ta, typename Tb> statslib_constexpr return_t<Ta> dexp(const Ta x, const Tb rate_par, const bool log_form = false);
Computes the density function.
Examples:
// parameters double rate = 14.0; // standard input double dens_val = stats::dexp(0.5,rate); double log_dens_val = stats::dexp(0.5,rate,true); // Armadillo input arma::mat X(10,1); X.fill(0.5); arma::mat dens_vals_mat = stats::dexp(X,rate); arma::mat log_dens_vals_mat = stats::dexp(X,rate,true);
Definition:
template<typename Ta, typename Tb> statslib_constexpr return_t<Ta> pexp(const Ta x, const Tb 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::pexp(0.5,rate); double log_prob_val = stats::pexp(0.5,rate,true); // Armadillo input arma::mat X(10,1); X.fill(0.5); arma::mat prob_vals_mat = stats::pexp(X,rate); arma::mat log_prob_vals_mat = stats::pexp(X,rate,true);
Definition:
template<typename Ta, typename Tb> statslib_constexpr Ta qexp(const Ta p, const Tb rate_par);
Computes the quantile function.
Examples:
// parameters double rate = 14.0; // standard input double quant_val = stats::qexp(0.7,rate); // Armadillo input arma::mat X(10,1); X.fill(0.7); arma::mat quant_vals_mat = stats::qexp(X,rate);
Definition:
// random engine seeding template<typename T> statslib_inline return_t<T> rexp(const T rate_par, rand_engine_t& engine); // seeding values template<typename T> statslib_inline return_t<T> rexp(const T rate_par, uint_t seed_val = std::random_device{}()); // matrix output template<typename mT, typename eT> statslib_inline mT rexp(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::rexp(rate); // Armadillo output: 10 x 1 matrix arma::mat rand_mat = stats::rexp<arma::mat>(10,1,rate);