Random Numbers with the random Header
Generate quality random numbers with modern engines and distributions.
Why Not rand()?
The legacy C std::rand() uses a global state, has poor statistical quality, and is not thread safe. Modern C++ provides much better tools in <random>.
The Three-Part Recipe
Random numbers in modern C++ involve three pieces:
- A seed source (true entropy)
- A generator engine (deterministic state)
- A distribution (shapes the output)
All lessons in this course
- Integer vs Floating Point Types
- The cmath Header: pow sqrt abs round
- Random Numbers with the random Header
- Numeric Limits and Overflow Behaviour