|
| | UniformRealDistribution () |
| | Default constructor. Creates a uniform distribution over [0, 1).
|
| |
| | UniformRealDistribution (RealType a, RealType b=RealType(1)) |
| | Constructs a uniform distribution with specified bounds.
|
| |
| | UniformRealDistribution (const param_type ¶m) |
| | Constructs from a parameter set.
|
| |
| void | reset () |
| | Resets the distribution state.
|
| |
| RealType | a () const |
| | Gets the lower bound of the distribution range.
|
| |
| RealType | b () const |
| | Gets the upper bound of the distribution range.
|
| |
| param_type | param () const |
| | Gets the current parameter set.
|
| |
| void | param (const param_type ¶m) |
| | Sets new parameters for the distribution.
|
| |
| result_type | min () const |
| | Gets the minimum value that can be generated (inclusive).
|
| |
| result_type | max () const |
| | Gets the maximum value that can be generated (exclusive).
|
| |
| template<typename Generator > |
| result_type | operator() (Generator &g) |
| | Generates the next random value using stored parameters.
|
| |
| template<typename Generator > |
| result_type | operator() (Generator &g, const param_type ¶m) |
| | Generates the next random value using provided parameters.
|
| |
template<typename RealType = double>
class Infinity::Engine::UniformRealDistribution< RealType >
Platform-independent uniform real distribution.
Produces floating-point values uniformly distributed over a specified range [a, b). Unlike std::uniform_real_distribution, this implementation guarantees identical results across different platforms and compilers by using a deterministic uint32 to float conversion method.
This distribution is essential for procedural generation where cross-platform reproducibility is critical. The same seed will produce identical sequences on Windows, Linux, and macOS regardless of compiler or standard library implementation.
- Template Parameters
-
| RealType | Floating point type (float or double) |
Example usage:
float value = dist(rng);
for (int i = 0; i < 100; ++i) {
float x = dist(rng);
}
float normalized = dist(rng);
Pseudo-random number generator for procedural generation.
Definition PRNG.hpp:48
- Note
- Results are guaranteed identical across platforms when using the same PRNG seed.
- Warning
- The upper bound b is exclusive; values are in [a, b), not [a, b].
template<typename RealType = double>
template<typename Generator >
Generates the next random value using provided parameters.
Uses a deterministic conversion from uint32 to floating point that ensures identical results across all platforms and compilers. The conversion divides by exactly 2^32 to map the full uint32 range to [0, 1).
- Template Parameters
-
| Generator | The random number generator type (e.g., PRNG) |
- Parameters
-
| g | The random number generator |
| param | The distribution parameters to use for this generation |
- Returns
- A random value uniformly distributed in [param.a(), param.b())