StatsLib Build Coverage Status

Watch Star Fork

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


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:

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


    // 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

To build the test files:

# clone stats
git clone -b master --single-branch ./stats
# compile tests
cd ./stats/tests