class
<random>
std::minstd_rand
typedef linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647> minstd_rand;
Minimal Standard minstd_rand generator
A simple multiplicative congruential pseudo-random number generator (a type of linear_congruential_engine).
The generator has a single value as state, which is modified by its transition algorithm on each advance like x is modified in the following piece of code:
|
x = x * 48271 % 2147483647
| |
It is an instantiation of the linear_congruential_engine with the following template parameters:
parameter | name | value | notes |
a | multiplier | 48271 | Prime multiplier |
c | increment | 0 | |
m | modulus | 2147483647 | 231-1 |
It is generally considered to generate slightly more random sequences than minstd_rand0 with the same overhead.
Member types
The following alias is a member type of minstd_rand:
member type | definition | notes |
result_type | uint_fast32_t | The type of the numbers generated. |
Member functions
As a linear_congruential_engine type, it has the following member functions:
- (constructor)
- Construct linear congruential 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
As a linear_congruential_engine type, the following operator overloads may be applied to it:
- 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 |
multiplier | 48271 | The multiplier (a) used in the transition algorithm on each advance. |
increment | 0 | The increment (c) used in the transition algorithm on each advance. |
modulus | 2147483647 | The modulus (m) used in the transition algorithm on each advance. |
default_seed | 1 | The default seed used on construction or seeding. |