Class LatticeRsg
The rank-1 lattice-rule low-discrepancy sequence generator: its i-th point is (i·z_j/N mod 1) in each dimension j, z a generating vector (LatticeRule) and N the number of points.
[WorkingType]
public sealed class LatticeRsg : IRsg
- Inheritance
-
LatticeRsg
- Implements
- Inherited Members
Remarks
A mutable working type: each draw changes it, and it is not thread-safe. A draw returns a view of its buffer, valid until its next draw.
Two departures from QuantLib's, each documented: SkipTo(long) moves to the n-th point, as QuantLib's other
sequences' skipTo do, where QuantLib's moves n points on (Divergences/LatticeRsgTests.cs); and a
dimension beyond the generating vector's, which QuantLib reads past its end, and a number of points below 1, a
division by 0, are refused.
Constructors
LatticeRsg(int, ImmutableArray<double>, long)
Initializes a new instance of the LatticeRsg class.
public LatticeRsg(int dimensionality, ImmutableArray<double> z, long n)
Parameters
dimensionalityintThe dimension of each point, from 0 to the generating vector's length.
zImmutableArray<double>The generating vector.
nlongThe number of points, at least 1.
Exceptions
- ArgumentOutOfRangeException
dimensionalityis negative or beyondz's length, ornis below 1.
Properties
Dimension
Gets the dimension of each sequence.
public int Dimension { get; }
Property Value
Methods
Clone()
Copies the generator deeply: the copy's next draw equals this one's, into its own buffer, and the two change apart.
public LatticeRsg Clone()
Returns
- LatticeRsg
The copy.
LastSequence()
Gets the point the last draw gave.
public Sample<ReadOnlyMemory<double>> LastSequence()
Returns
- Sample<ReadOnlyMemory<double>>
The point, a view of the generator's buffer valid until its next draw, and its weight, 1.
NextSequence()
Draws the next point.
public Sample<ReadOnlyMemory<double>> NextSequence()
Returns
- Sample<ReadOnlyMemory<double>>
The point, a view of the generator's buffer valid until its next draw, and its weight, 1.
SkipTo(long)
Skips to the n-th point of the sequence: the next draw is the point of index
index.
public void SkipTo(long index)
Parameters
indexlongThe point's index, from 0.
Exceptions
- ArgumentOutOfRangeException
indexis negative.