Showing content from https://cplusplus.com/reference/random/mersenne_twister_engine/ below:
class template
<random>
std::mersenne_twister_engine
template <class UIntType, size_t w, size_t n, size_t m, size_t r, UIntType a, size_t u, UIntType d, size_t s, UIntType b, size_t t, UIntType c, size_t l, UIntType f> class mersenne_twister_engine;
Mersenne twister random number engine
A pseudo-random number generator engine that produces unsigned integer numbers in the closed interval [0,2w-1].
The algorithm used by this engine is optimized to compute large series of numbers (such as in Monte Carlo experiments) with an almost uniform distribution in the range.
The engine has an internal state sequence of n integer elements, which is filled with a pseudo-random series generated on construction or by calling member function seed.
The internal state sequence becomes the source for n elements: When the state is advanced (for example, in order to produce a new random number), the engine alters the state sequence by twisting the current value using xor mask a on a mix of bits determined by parameter r that come from that value and from a value m elements away (see operator() for details).
The random numbers produced are tempered versions of these twisted values. The tempering is a sequence of shift and xor operations defined by parameters u, d, s, b, t, c and l applied on the selected state value (see operator()).
The random numbers generated by mersenne_twister_engine have a period equivalent to the mersenne number 2(n-1)*w-1.
Template parameters
-
UIntType
-
An unsigned integer type.
Values produced by the engine are of this type.
-
w
-
Word size: Number of bits of each word in the state sequence.
This parameter should be lower or equal to numeric_limits<UIntType>::digits.
-
n
-
State size: Number of elements in the state sequence. This determines the degree of recurrence in the generated series.
-
m
-
Shift size: On each twist, the elements are transformed using other values in the sequence that are m elements away.
This parameter should be lower than or equal to n.
-
r
-
Mask bits: The number of bits that mark the separation point of words on each twist.
This parameter should be lower than or equal to w.
-
a
-
Xor Mask: The XOR mask to be applied as the linear function on each twist.
This parameter should be lower than (1u<<w).
-
s, t, u, l
-
Tempering shift parameters: Shift values for the scrambling operation used by the generation algorithm.
These parameters should be lower than or equal to w.
-
b, c, d
-
Tempering bitmask parameters: Bitmask values for the scrambling operation used by the generation algorithm.
These parameters should be lower than (1u<<w).
-
f
-
Initialization multiplier: The initialization multiplier used to seed the state sequence when a single value is used as seed.
Template instantiations
-
mt19937
-
Mersenne Twister 19937 generator (class)
-
mt19937_64
-
Mersenne Twister 19937 generator (64 bit) (class)
Member types The following alias is a member type of mersenne_twister_engine:
member type definition notes result_type The first template parameter (UIntType) The type of the numbers generated.
Member functions
-
(constructor)
-
Construct mersenne twister engine (public member function)
-
min
-
Minimum value (public static member function)
-
max
-
Maximum value (public static member function)
-
seed
-
Seed engine (public member function)
-
operator()
-
Generate random number (public member function)
-
discard
-
Advance internal state (public member function)
Non-member functions
-
operator<<
-
Insert into output stream (function template)
-
operator>>
-
Extract from input stream (function template)
-
relational operators
-
Relational operators (function template)
Member constexpr constants member constant definition notes word_size The second template parameter (w) The number of bits of each word in the state sequence. state_size The third template parameter (n) The number of elements in the state sequence (degree of recurrence). shift_size The fourth template parameter (m) The shift size used on twists to transform the values. mask_bits The fifth template parameter (r) The number of bits that mark the separation point of words on each twist. xor_mask The sixth template parameter (a) The XOR mask applied as the linear function on each twist. tempering_u The seventh template parameter (u) The shift size of parameter u used in the tempering process of the generation algorithm. tempering_d The eighth template parameter (d) The XOR mask used as parameter d in the tempering process of the generation algorithm. tempering_s The ninth template parameter (s) The shift size of parameter s used in the tempering process of the generation algorithm. tempering_b The tenth template parameter (b) The XOR mask used as parameter b in the tempering process of the generation algorithm. tempering_t The eleventh template parameter (t) The shift size of parameter t used in the tempering process of the generation algorithm. tempering_c The twelfth template parameter (c) The XOR mask used as parameter c in the tempering process of the generation algorithm. tempering_l The thirteenth template parameter (l) The shift size of parameter l used in the tempering process of the generation algorithm. initialization_multiplier The fourteenth template parameter (f) The initialization multiplier used to seed the state sequence when a single value is used as seed. default_seed 5489u The default seed used on construction or seeding.
See also
-
linear_congruential_engine
-
Linear congruential random number engine (class template)
-
subtract_with_carry_engine
-
Subtract-with-carry random number engine (class template)
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4