Table of Contents

Class ZigguratGaussianRng<TRng>

Namespace
NanoQL.Numerics
Assembly
NanoQL.dll

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

TRng

The 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

source ZigguratGaussianRng<TRng>

The generator to copy, deeply.

Exceptions

ArgumentNullException

source is null.

ZigguratGaussianRng(TRng)

Initializes a new instance of the ZigguratGaussianRng<TRng> class.

public ZigguratGaussianRng(TRng uint64Generator)

Parameters

uint64Generator TRng

The generator, which the Gaussian generator copies.

Exceptions

ArgumentNullException

uint64Generator is 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

Sample<double>

The sample, with weight 1.0.

NextReal()

Draws a random number from a Gaussian distribution.

public double NextReal()

Returns

double

The number.