Random number generators

TRIQS exposes to python the random number generators used in C++, in the module RandomGenerator. The generators are the boost random generators.

Usage

The generator is constructed from a name (the name of the boost generator) and a seed:

from triqs.random_generator import *
r = RandomGenerator("mt19937", 237849)

A list of available random generators is obtained with:

print random_generator_names_list()

Then you can either generate float number on the interval \([0,1[\) simply by calling the generator, or integer numbers in the inverval \([0,N-1]\) by calling it with N

print r()
print r(10)

Example

Here’s a simple example showing how to use the generator.

from triqs.random_generator import *
from triqs.plot.mpl_interface import *

r = RandomGenerator("lagged_fibonacci607", 237489)
l = []
for i in range(10000): l += [r(),]
plt.hist(l, 30, density=True)
../../../../_images/random.png

Complete documentation/manual/triqs

class triqs.random_generator.RandomGenerator
triqs.random_generator.random_generator_names_list()

Signature : () -> list[str] Get a list of available random generator names