Table of Contents

Class BoxMullerGaussianRng<TRng>

Namespace
NanoQL.Numerics
Assembly
NanoQL.dll

The Gaussian random-number generator by the well-known Box-Muller transformation: normally distributed deviates with average 0.0 and standard deviation 1.0, from uniform deviates in (0, 1) supplied by TRng.

[WorkingType]
public class BoxMullerGaussianRng<TRng> : IRng where TRng : class, IRng

Type Parameters

TRng

The uniform generator, of deviates in (0, 1).

Inheritance
BoxMullerGaussianRng<TRng>
Implements
Derived
Inherited Members

Remarks

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. Each pair of uniform draws gives two deviates, returned one after the other with the pair's weight.

Constructors

BoxMullerGaussianRng(BoxMullerGaussianRng<TRng>)

Initializes a new instance of the BoxMullerGaussianRng<TRng> class from a copy of another, for a subclass's Clone().

protected BoxMullerGaussianRng(BoxMullerGaussianRng<TRng> source)

Parameters

source BoxMullerGaussianRng<TRng>

The generator to copy, deeply.

Exceptions

ArgumentNullException

source is null.

BoxMullerGaussianRng(TRng)

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

public BoxMullerGaussianRng(TRng uniformGenerator)

Parameters

uniformGenerator TRng

The uniform generator, which the generator copies.

Exceptions

ArgumentNullException

uniformGenerator 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 BoxMullerGaussianRng<TRng> Clone()

Returns

BoxMullerGaussianRng<TRng>

The copy.

Next()

Draws a sample from a Gaussian distribution.

public Sample<double> Next()

Returns

Sample<double>

The sample, with the weight of the uniform pair it comes from.