Random Class
Utility class for generating pseudo-random numbers. More...
Declaration
Public Constructors Index
| Random (const uint32_t seed) | |
|
Initializes the generator with the provided seed value. More... | |
Public Member Functions Index
| void | reset () |
|
Resets the generator to its initial state. More... | |
| float | randomFloat (float a, float b) noexcept |
|
Generates a pseudo-random float in the range [a, b). More... | |
Private Member Attributes Index
| std::mt19937 | gen_ |
|
The Mersenne Twister pseudo-random number generator. More... | |
| std::uniform_real_distribution< float > | uniformDist_ |
|
Uniform real distribution for generating floating-point numbers. More... | |
| uint32_t | initialSeed_ |
|
The initial seed used to initialize the generator. More... | |
Description
Utility class for generating pseudo-random numbers.
This class provides a random number generator based on the Mersenne Twister algorithm (std::mt19937).
Example usage:
Definition at line 27 of file Random.ixx.
Public Member Functions
randomFloat()
Generates a pseudo-random float in the range [a, b).
Uses std::uniform_real_distribution to generate a uniformly distributed floating-point number.
- Parameters
-
a The lower bound of the range (inclusive).
b The upper bound of the range (exclusive).
- Returns
A random float value in the range [a, b).
Definition at line 85 of file Random.ixx.
Reference helios::registerComponents.
reset()
| inline |
Resets the generator to its initial state.
Re-seeds the generator with the original seed value and resets the distribution state. Useful for reproducible sequences.
Definition at line 66 of file Random.ixx.
Private Member Attributes
gen_
|
The Mersenne Twister pseudo-random number generator.
Definition at line 34 of file Random.ixx.
initialSeed_
|
The initial seed used to initialize the generator.
Stored for use by reset() to restore the generator to its initial state.
Definition at line 49 of file Random.ixx.
uniformDist_
|
Uniform real distribution for generating floating-point numbers.
Definition at line 41 of file Random.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.