|
RandLib 2.0.0
Probability distributions, fitting, and heavy-tail tools for C++20
|
Fit probability distributions and handle heavy tails in modern C++. RandLib is a dependency-free, header-only C++20 library for sampling, probability functions, moments, parameter estimation, model selection, goodness-of-fit testing, extreme-value analysis, and stable laws.
RandLib 2 is the current C++20 release line. The source-compatible C++17 maintenance release remains available on 1.x; see the v1 to v2 migration guide.
Every sampler accepts any standard uniform random bit generator. Fitting returns a new distribution; it never mutates the model used to create the data.
| Library | Sampling | PDF/CDF/quantiles | Fitting and diagnostics | Heavy-tail focus | Prefer it when… |
|---|---|---|---|---|---|
C++ <random> | Yes | No | No | No | You only need the standard set of portable samplers. |
| Boost.Math | Separate Boost.Random library | Excellent, including multiprecision and configurable policies | No general fitting API | Some heavy-tailed laws | Accuracy, multiprecision, or mature special functions matter most. |
| StatsLib | Yes | Yes, with optional matrix APIs | No general fitting API | Limited | You prefer an R-like functional API or Eigen/Armadillo/Blaze integration. |
| RandLib | Yes | Yes | MLE, moments, conjugate Bayes, model selection, goodness-of-fit, censoring and truncation | Stable, Pareto, GPD/GEV and tail estimators | One object-oriented library should cover simulation through fitted heavy-tail models. |
These projects are complementary. See the standard <random> inventory, Boost.Math distribution reference, and StatsLib feature list for their current scope.
Add include/ to your compiler's include path, use the generated single header, or install with CMake 3.21 or newer:
The project also supplies a vcpkg overlay port and a Conan 2 recipe. Build controls include:
RANDLIB_BUILD_TESTS, RANDLIB_BUILD_EXAMPLES, RANDLIB_BUILD_BENCHMARKS, and RANDLIB_BUILD_DOCS;RANDLIB_WARNINGS_AS_ERRORS for project-owned targets;RANDLIB_PRECOMPILED to compile common explicit instantiations once; andRANDLIB_PORTABLE_SPECIAL_FUNCTIONS to force RandLib's Bessel, beta, and zeta implementations.The changelog records behavior changes and known limitations. Numerical claims are backed by committed high-precision reference data; documented exceptions are tracked in tests/data/reference_tolerances.csv.
Supported CI compilers include GCC 11–14, Clang 15–18, AppleClang, and MSVC 2022. The library is MIT licensed.