Introduction

The density function of the $F$-distribution:

$$ f(x; d_1, d_2) = \frac{1}{\mathcal{B} \left( \frac{d_1}{2}, \frac{d_2}{2} \right)} \left( \frac{d_1}{d_2} \right)^{\frac{d_1}{2}} x^{d_1/2 - 1} \left(1 + \frac{d_1}{d_2} x \right)^{- \frac{d_1+d_2}{2}} \times \mathbf{1} [x \geq 0] $$

Parameters:

  • df1_par is $d_1$.
  • df2_par is $d_2$.

Density


Definition:

 
template<typename Ta, typename Tb>
statslib_constexpr
return_t<Ta> df(const Ta x, const Tb df1_par, const Tb df2_par, const bool log_form = false);

Computes the density function.


Examples:

// parameters
double df1 = 10.0;
double df2 = 12.0;

// standard input
double dens_val = stats::df(1.5,df1,df2);
double log_dens_val = stats::df(1.5,df1,df2,true);

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

arma::mat dens_vals_mat = stats::df(X,df1,df2);
arma::mat log_dens_vals_mat = stats::df(X,df1,df2,true);

Probability


Definition:

 
template<typename Ta, typename Tb>
statslib_constexpr
return_t<Ta> pf(const Ta x, const Tb df1_par, const Tb df2_par, const bool log_form = false);

Computes the cumulative distribution function (CDF).


Examples:

// parameters
double df1 = 10.0;
double df2 = 12.0;

// standard input
double prob_val = stats::pf(1.5,df1,df2);
double log_prob_val = stats::pf(1.5,df1,df2,true);

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

arma::mat prob_vals_mat = stats::pf(X,df1,df2);
arma::mat log_prob_vals_mat = stats::pf(X,df1,df2,true);

Quantile


Definition:

 
template<typename Ta, typename Tb>
statslib_constexpr
Ta qf(const Ta p, const Tb df1_par, const Tb df2_par);

Computes the quantile function.


Examples:

// parameters
double df1 = 10.0;
double df2 = 12.0;

// standard input
double quant_val = stats::qf(0.7,df1,df2);

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

arma::mat quant_vals_mat = stats::qf(X,df1,df2);

Random Sampling


Definition:

 
// random engine seeding
template<typename T>
statslib_inline
return_t<T> rf(const T df1_par, const T df2_par, rand_engine_t& engine);

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

// matrix output
template<typename mT, typename eT>
statslib_inline
mT rf(const uint_t n, const uint_t k, const eT df1_par, const eT df2_par);

Generates pseudo-random draws.


Examples:

// parameters
double df1 = 10.0;
double df2 = 12.0;

// standard input
double rand_val = stats::rf(df1,df2);

// Armadillo output: 10 x 1 matrix
arma::mat rand_mat = stats::rf<arma::mat>(10,1,df1,df2);