# Overview: Random numbers

To be able to have a unified interface for algorithms that require random numbers we provide a base class RandomGenerator with methods to produces this from whatever library you want. This is by default std::mt19937, but we also provide a wrapper on the GSL library. If you want something else just make a class that inherits from the base class and implement the required methods.

# Creating random numbers

How to produce uniform/normal random numbers:

using namespace FML::RANDOM;
RandomGenerator r;

// Uniform distribution
r.set_uniform_range(2.0, 5.0);

// Normal distribution (mu,sigma)
r.set_normal_range(0.0, 1.0);

std::cout << r.generate_uniform() << "\n";
std::cout << r.generate_normal()  << "\n";


If you want to use GSL (fiducial is gsl_rng_ranlxd1, but can be changed in headerfile) then:

std::unique_ptr<RandomGenerator> r = std::make_unqiue<GSLRandomGenerator> ();
r->set_uniform_range(2.0, 5.0);
std::cout << r->generate_uniform() << "\n";


We also provide methods for cloning the state of a RNG which is very useful for parallel algorithms.