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 Apache License, Version 2.0.

**Available Distributions and Examples**

Functions to compute the cdf, pdf, and quantile, as well as random sampling, are available for the following distributions:

- Bernoulli
- Beta
- Binomial
- Cauchy
- Chi-squared
- Exponential
- F
- Gamma
- inverse-Gamma
- Laplace
- Logistic
- Log-Normal
- Normal (Gaussian)
- Poisson
- Student's t
- Uniform
- Weibull

In addition, pdf and randomization functions are available for several multivariate distributions:

- 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<arma::mat>(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