I want a C++ library which would allow me to dynamically construct a distribution, from a wide selection of distribution families, with its appropriate parameters, based on configuration data read from disk or from console (rather than deciding which distribution it is at compile-time, i.e. not just selection via template parameters). I need to be able to use this constructed distribution to (relatively) efficiently generate large amounts of data.


  • Libre
  • Gratis
  • Available for Linux and Windows
  • Ability to create composed distributions from existing ones (e.g. the application of some f: R^2->R to pairs of random variables with known distributions).


  • Support for explicitly-specified distributions over small finite domains
  • Support for distributions over complex numbers
  • Support for distributions over more complicated types (variants, tuples, optionals etc.)
  • C++17, or at least C++11
  • Known to work with many compilers, including clang, gcc and msvc
  • No Boost dependencies
  • Used in more than toy projects
  • Actively maintained
  • Plays nice with the standard library distributions

Don't care:

  • Compiled or header-only
  • Pseudorandom or using hardware entropy sources

1 Answer 1


C++11 includes a number of statistical distributions without a Boost requirement:


For composing or mixing distributions, see this example:


This should be all that you need. If not, there is a header-only library containing a number of other useful statistical distributions here:


The same author also has C++ MCMC and optimization libraries.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.