# Pseudo random number generators

uniform and non-uniform distributions

This page contains software libraries for some very good random number generators.

The basic random number generators make floating point or integer random numbers with uniform distributions. This code is available in C++ language and as binary function libraries for several different platforms.

The non-uniform random number generators make random variates with several different distributions. This code is available in C++ language.

Code examples are included, showing how to use these software libraries.

All code is provided with open source under the Gnu general public license.

These generators are intended for Monte Carlo applications, not for cryptographic applications.

## Download packages:

- Random number generator for large applications using vector instructions
__Description__: The Ranvec1 C++ code is part of the vector class library (VCL). It is intended for large applications using the vector instructions and multiprocessing capabilities of modern computers, including the AVX2 and AVX512 instruction sets. Can generate floating point or integer random numbers with uniform distribution, and random bits. Very good randomness, high resolution, extremely long cycle lengths, and high speed.

__System requirements__: Windows, Linux or Mac OS. Gnu, Clang, Intel or Microsoft C++ compiler.

Theoretical discussion

__File name__: vectorclass.zip, size: 664327, last modified: 2016-Sep-27.

Download C++ vector class library including random number generator.

- Uniform random number generators in C++
__Description__: C++ class library containing the following random number generators: Mersenne twister, SFMT and Mother-of-all. Can generate floating point or integer random numbers with uniform distribution, and random bits. Very good randomness, high resolution, extremely long cycle lengths, and high speed. Supports multi-threaded applications. Examples included.

__System requirements__: Any C++ compiler, any operating system.

Further description and instructions

__File name__: randomc.zip, size: 471048, last modified: 2014-Jun-14.

Download C++ random number generators.

- Uniform random number generators as binary libraries
__Description__: Contains the same random number generators as the abovementioned C++ package, but implemented as binary libraries in *.lib, *.dll and *.a files. Coded in assembly language for optimal speed. Supports many different compilers and operating systems, including 32-bit and 64-bit Windows, Linux, BSD and Intel-based Mac.

__System requirements__: Any x86 or x86-64 platform. Can be called from compiled languages such as C and C++.

Further description and instructions

__File name__: asmlib.zip, size: 895582, last modified: 2015-Dec-19.

Download random number generator binary libraries.

- Non-uniform random number generators in C++
__Description__: C++ class library generating random numbers with the following distributions: normal, truncated normal, bernoulli, poisson, binomial, hypergeometric, Wallenius' and Fisher's noncentral hypergeometric, multinomial, multivariate hypergeometric, and multivariate Fisher's and Wallenius' noncentral hypergeometric distributions. A function for shuffling numbers is also provided. Includes C++ examples showing how to use these functions for simulating evolution and for other purposes.

Most of the functions are fast and accurate, even for extreme values of the parameters.

You have the choice of using any of the uniform random number generators in the above C++ libraries or binary libraries as base for these non-uniform random number generators.

Further description and instructions.

Definition of distributions pdf format.

Wallenius' noncentral hypergeometric distribution theory.

Theoretical description of sampling methods used pdf format.

__File name__: stocc.zip, size: 785743, last modified: 2014-Jun-14.

Download non-uniform random number generators.

- List of random numbers
__Description__: A list of 10000 random numbers generated with a combined generator.

__File name__: 10000ran.zip, size: 49098, last modified: 2005-May-24.

Download 10000 random numbers.

- R package for noncentral hypergeometric distributions
__Description__: Package for the R language (www.r-project.org) for calculating the various noncentral hypergeometric distributions. Useful for biased urn models, models of biased sampling and evolution by natural selection.

__Package name__: BiasedUrn, last modified: 2013-12-29.

BiasedUrn.

Comments to the theory of these random number generators can be posted to my discussion board.

**Please don't mail me with your programming problems. Your mail will not be answered.**

## Links to related sites

- Efficient pseudo random number vector generators are included in my Vector Class Library:
www.agner.org/optimize/#vectorclass

- PLAB: A Server on the Theory and Practice of
Random Number Generation

- The R Project for Statistical Computing.
Free software system for mathematical and statistical computing.

- Ernst Stadlober's
page on non-uniform random number generation, including the Win-rand
package which contains many other distributions than the ones supplied here,
and a graphic interface to show the distribution curves.

- Ranlib: library of functions for random number generators and non-uniform
variates ftp://odin.mda.uth.tmc.edu/pub/source and
ftp://odin.mda.uth.tmc.edu/pub/msdos

- Matsumoto's Mersenne Twister RNG:
www.math.sci.hiroshima-u.ac.jp/~m-mat/eindex.html

- Random number generators in C++11 standard libraries:
en.cppreference.com/w/cpp/numeric/random

- RngPack: Random number generators for Java: www.honeylocust.com/RngPack/

- Regress: Statistics package for Macintosh:
www.causaScientia.org/software/Regress_plus.html

1246907