Class ZigguratGaussianRng<TRng>
The Gaussian random-number generator by the ziggurat transformation: normally distributed deviates with average
0.0 and standard deviation 1.0, from random integers in the [0, 0xffffffffffffffff] interval supplied by
TRng.
[WorkingType]
public class ZigguratGaussianRng<TRng> : IRng where TRng : class, IInt64Rng
Type Parameters
TRngThe generator of 64-bit integers and uniform reals.
- Inheritance
-
ZigguratGaussianRng<TRng>
- Implements
- Derived
- Inherited Members
Remarks
For a more detailed description see the article "An Improved Ziggurat Method to Generate Normal Random Samples" by Jurgen A. Doornik (https://www.doornik.com/research/ziggurat.pdf). QuantLib's code is inspired by the rust implementation in https://github.com/rust-random/rand/blob/d42daabf65a3ceaf58c2eefc7eb477c4d5a9b4ba/rand_distr/src/normal.rs and https://github.com/rust-random/rand/blob/d42daabf65a3ceaf58c2eefc7eb477c4d5a9b4ba/rand_distr/src/utils.rs.
A mutable working type: each draw changes it, and it is not thread-safe. It copies the generator it is given, so the caller's later draws change nothing in it. Xoshiro256StarStarUniformRng is the only generator that implements IInt64Rng, as in QuantLib.
Constructors
ZigguratGaussianRng(ZigguratGaussianRng<TRng>)
Initializes a new instance of the ZigguratGaussianRng<TRng> class from a copy of another, for a subclass's Clone().
protected ZigguratGaussianRng(ZigguratGaussianRng<TRng> source)
Parameters
sourceZigguratGaussianRng<TRng>The generator to copy, deeply.
Exceptions
- ArgumentNullException
sourceis null.
ZigguratGaussianRng(TRng)
Initializes a new instance of the ZigguratGaussianRng<TRng> class.
public ZigguratGaussianRng(TRng uint64Generator)
Parameters
uint64GeneratorTRngThe generator, which the Gaussian generator copies.
Exceptions
- ArgumentNullException
uint64Generatoris null.
Methods
Clone()
Copies the generator deeply, its uniform generator included: the copy's next draw equals this one's, and the two change apart.
public virtual ZigguratGaussianRng<TRng> Clone()
Returns
- ZigguratGaussianRng<TRng>
The copy.
Next()
Draws a sample from a Gaussian distribution.
public Sample<double> Next()
Returns
NextReal()
Draws a random number from a Gaussian distribution.
public double NextReal()
Returns
- double
The number.