StatsLib is a templated C++ library for fast computation of statistical distribution functions.

Features

- Compile-time (or run-time) evaluation of density functions, cumulative distribution functions, and quantile functions.
- Effective use of C++11 constexpr functions with the GCE-Math library.
- Clean
**R**-like syntax.
- Built on the Armadillo C++ linear algebra library for fast and efficient matrix-based computation.

**Author**: Keith O'Hara

**License**: StatsLib is licensed under the GNU General Public License (GPL) version 2, or (at your option) any later version.

**Available Distributions and Examples**

cdf, pdf, quantile, and random variable generation:

- Bernoulli
- Beta
- Binomial
- Cauchy
- Chi-squared
- Exponential
- Gamma
- inverse-Gamma
- Laplace
- Logistic
- Log-Normal
- Normal (Gaussian)
- Uniform

pdf and random variable generation only:

- inverse-Wishart
- Multivariate Normal
- Wishart

Examples:

// evaluate the normal PDF at x = 1, mu = 0, sigma = 1
double dval_1 = stats::dnorm(1.0,0.0,1.0)
// evaluate the normal PDF at x = 1, mu = 0, sigma = 1, and return the log value
double dval_2 = stats::dnorm(1.0,0.0,1.0,true)
// evaluate the normal CDF at x = 1, mu = 0, sigma = 1
double pval_1 = stats::pnorm(1.0,0.0,1.0)
// evaluate the Laplacian quantile at p = 0.1, mu = 0, sigma = 1
double qval_1 = stats::qlaplace(0.1,0.0,1.0)
// matrix input of beta-distributed random variables
arma::mat beta_rvs = stats::rbeta(100,100,3.0,2.0);
arma::mat beta_cdf_vals = stats::pbeta(beta_rvs,3.0,2.0);

**Download and Installation**

- The source code is available on GitHub.
- StatsLib is a header-only library. Simply include the StatsLib header files with your project.

To build the test files:

# clone stats
git clone -b master --single-branch https://github.com/kthohr/stats ./stats
# compile tests
cd ./stats/tests
./cov_setup