Processing math: 100%


Introduction

The density function of the Cauchy distribution:

f(x;μ,σ)=1πσ[1+(xμσ)2]

Parameters:

  • mu_par is μ
  • sigma_par is σ

Density


Definition:

1
2
3
template<typename Ta, typename Tb>
statslib_constexpr
return_t<Ta> dcauchy(const Ta x, const Tb mu_par, const Tb sigma_par, const bool log_form = false);

Computes the density function.


Examples:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// parameters
double mu = 0.0;
double sigma = 1.0;
 
// standard input
double dens_val = stats::dcauchy(0.5,mu,sigma);
double log_dens_val = stats::dcauchy(0.5,mu,sigma,true);
 
// Armadillo input
arma::mat X(10,1);
X.fill(0.5);
 
arma::mat dens_vals_mat = stats::dcauchy(X,mu,sigma);
arma::mat log_dens_vals_mat = stats::dcauchy(X,mu,sigma,true);

Probability


Definition:

1
2
3
template<typename Ta, typename Tb>
statslib_constexpr
return_t<Ta> pcauchy(const Ta x, const Tb mu_par, const Tb sigma_par, const bool log_form = false);

Computes the cumulative distribution function (CDF).


Examples:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// parameters
double mu = 0.0;
double sigma = 1.0;
 
// standard input
double prob_val = stats::pcauchy(0.5,mu,sigma);
double log_prob_val = stats::pcauchy(0.5,mu,sigma,true);
 
// Armadillo input
arma::mat X(10,1);
X.fill(0.5);
 
arma::mat prob_vals_mat = stats::pcauchy(X,mu,sigma);
arma::mat log_prob_vals_mat = stats::pcauchy(X,mu,sigma,true);

Quantile


Definition:

1
2
3
template<typename Ta, typename Tb>
statslib_constexpr
return_t<Ta> qcauchy(const Ta p, const Tb mu_par, const Tb sigma_par);

Computes the quantile function.


Examples:

1
2
3
4
5
6
7
8
9
10
11
12
// parameters
double mu = 0.0;
double sigma = 1.0;
 
// standard input
double quant_val = stats::qcauchy(0.7,mu,sigma);
 
// Armadillo input
arma::mat X(10,1);
X.fill(0.7);
 
arma::mat quant_vals_mat = stats::qcauchy(X,mu,sigma);

Random Sampling


Definition:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// random engine seeding
template<typename T>
statslib_inline
return_t<T> rcauchy(const T mu_par, const T sigma_par, rand_engine_t& engine);
 
// seeding values
template<typename T>
statslib_inline
return_t<T> rcauchy(const T mu_par, const T sigma_par, uint_t seed_val = std::random_device{}());
 
// matrix output
template<typename mT, typename eT>
statslib_inline
mT rcauchy(const uint_t n, const uint_t k, const eT mu_par, const eT sigma_par);

Generates pseudo-random draws.


Examples:

1
2
3
4
5
6
7
8
9
// parameters
double mu = 0.0;
double sigma = 1.0;
 
// standard input
double rand_val = stats::rcauchy(mu,sigma);
 
// Armadillo output: 10 x 1 matrix
arma::mat rand_mat = stats::rcauchy<arma::mat>(10,1,mu,sigma);