Class BoxMullerGaussianRng<TRng>
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
TRngThe 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
sourceBoxMullerGaussianRng<TRng>The generator to copy, deeply.
Exceptions
- ArgumentNullException
sourceis null.
BoxMullerGaussianRng(TRng)
Initializes a new instance of the BoxMullerGaussianRng<TRng> class.
public BoxMullerGaussianRng(TRng uniformGenerator)
Parameters
uniformGeneratorTRngThe uniform generator, which the generator copies.
Exceptions
- ArgumentNullException
uniformGeneratoris 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()