28 Numerics library [numerics]

28.5 Random number generation [rand]

28.5.8 Utilities [rand.util] Function template generate_canonical [rand.util.canonical]

template<class RealType, size_t bits, class URBG> RealType generate_canonical(URBG& g);
Effects: Invokes g() k times to obtain values , respectively.
Calculates a quantity
using arithmetic of type RealType.
Returns: .
[Note 1: 
— end note]
Throws: What and when g throws.
Complexity: Exactly invocations of g, where b230 is the lesser of numeric_limits<RealType>​::​digits and bits, and R is the value of .
[Note 2: 
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.