mirror of
https://github.com/triqs/dft_tools
synced 2024-12-27 06:43:40 +01:00
e6529b608e
- Use a new buffered_function to replace the complicated generator code from ALPS. - Clean the implementation of the random_generator - update the documentation - update to the new python wrapper (could not be done with the previous version, because of lack of move constructor).
50 lines
1.1 KiB
ReStructuredText
50 lines
1.1 KiB
ReStructuredText
.. index:: Random number generator
|
|
|
|
.. module:: pytriqs.random_generator
|
|
|
|
.. _random_generator:
|
|
|
|
Random generator class
|
|
======================
|
|
|
|
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 pytriqs.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 :math:`[0,1[`
|
|
simply by calling the generator, or integer numbers in the inverval :math:`[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.
|
|
|
|
.. plot:: reference/python/random/random.py
|
|
:include-source:
|
|
:scale: 70
|
|
|
|
|
|
Complete reference
|
|
------------------
|
|
|
|
.. autoclass:: pytriqs.random_generator.RandomGenerator
|
|
:members:
|
|
|
|
.. autofunction:: pytriqs.random_generator.random_generator_names_list
|