Normal deviates. More...
|template<class Random >|
|RealType||operator() (Random &r, RealType mu=RealType(0), RealType sigma=RealType(1)) const throw ()|
Sample from the normal distribution.
This uses the ratio method; see Knuth, TAOCP, Vol 2, Sec. 3.4.1.C, Algorithm R. Unlike the Box-Muller method which generates two normal deviates at a time, this method generates just one. This means that this class has no state that needs to be saved when checkpointing a calculation. Original citation is
A. J. Kinderman, J. F. Monahan,
Computer Generation of Random Variables Using the Ratio of Uniform Deviates,
ACM TOMS 3, 257–260 (1977).
Improved "quadratic" bounds are given by
J. L. Leva,
A Fast Normal Random Number Generator,
ACM TOMS 18, 449–453 and 454–455 (1992).
The log is evaluated 1.369 times per normal deviate with no bounds, 0.232 times with Knuth's bounds, and 0.012 times with the quadratic bounds. Time is approx 0.3 us per deviate (1GHz machine, optimized, RealType = float).
|RealType||the real type of the results (default double).|
|typedef RealType RandomLib::NormalDistribution< RealType >::result_type|
Return a sample of type RealType from the normal distribution with mean μ and standard deviation σ.
For μ = 0 and σ = 1 (the defaults), the distribution is symmetric about zero and is nonzero. The maximum result is less than 2 sqrt(log(2) p) where p is the precision of real type RealType. The minimum positive value is approximately 1/2p+1. Here p is the precision of real type RealType.
|Random||the type of RandomCanonical generator.|
|[in,out]||r||the RandomCanonical generator.|
|[in]||mu||the mean value of the normal distribution (default 0).|
|[in]||sigma||the standard deviation of the normal distribution (default 1).|