26 Numerics library [numerics]

26.6 Random number generation [rand]

26.6.7 Utilities [rand.util]

26.6.7.2 Function template generate_­canonical [rand.util.canonical]

template<class RealType, size_t bits, class URBG> RealType generate_canonical(URBG& g);
Complexity: Exactly invocations of g, where b246 is the lesser of numeric_­limits<RealType>​::​digits and bits, and R is the value of .
Effects: Invokes g() k times to obtain values , respectively.
Calculates a quantity
using arithmetic of type RealType.
Returns: .
[Note
:
.
— end note
]
Throws: What and when g throws.
[Note
:
If the values produced by g are uniformly distributed, the instantiation's results are distributed as uniformly as possible.
Obtaining a value in this way can be a useful step in the process of transforming a value generated by a uniform random bit generator into a value that can be delivered by a random number distribution.
— end note
]
b is introduced to avoid any attempt to produce more bits of randomness than can be held in RealType.
⮥