triqs.mc_tools.random_generator.RandomGenerator

class triqs.mc_tools.random_generator.RandomGenerator

Bases: object

Random number generator with a selectable underlying engine.

The following engine names are currently accepted by the constructor:

  • empty string – a built-in custom Mersenne Twister RNG

  • mt19937

  • mt11213b

  • lagged_fibonacci607

  • lagged_fibonacci1279

  • lagged_fibonacci2281

  • lagged_fibonacci3217

  • lagged_fibonacci4423

  • lagged_fibonacci9689

  • lagged_fibonacci19937

  • lagged_fibonacci23209

  • lagged_fibonacci44497

  • ranlux3

For non-empty names, the underlying engine is provided by boost.random.

For performance reasons, we use a buffer for the generated random numbers to avoid some of the costs of repeated function calls to the RNG.


Dispatched C++ constructor(s).

[1] ()

[2] (name: str, seed: int, buffer_size: int = 1000)

[1] Default constructor uses the mt19937 engine with the default seed.


[2] Construct a random generator by wrapping the specified RNG and seeding it with the given seed.

The given name has to correspond to one of the supported engines. If the name does not match any of the supported engines, a runtime error is raised.

An empty name selects the built-in custom Mersenne Twister RNG.


Parameters:
namestr

Name of the RNG to be used.

seedint

Seed for the RNG.

buffer_sizeint

Size of the buffer used to store random numbers.

Methods

__call__(*args, **kwargs)

Call self as a function.

name

Get the name of the underlying RNG.

preview

Look ahead at the next value that will be generated when the generator is called.