StatsLib

StatsLib Build Coverage Status

Watch Star Fork


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


Features


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:

pdf and random variable generation only:

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

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