Class HaltonRsg
The Halton low-discrepancy sequence generator. For more details see chapter 8, paragraph 2 of "Monte Carlo Methods in Finance", by Peter Jäckel.
[WorkingType]
public sealed class HaltonRsg : ISeedableRsg<HaltonRsg>, IRsg
- Inheritance
-
HaltonRsg
- Implements
- Inherited Members
Remarks
A mutable working type: each draw changes the generator, and it is not thread-safe. A draw returns a view of the generator's buffer, valid until its next draw.
The seed, in [1, 4294967295], is only used when randomStart or randomShift is true; QuantLib's seed
0, which there draws a seed from the clock, is refused. The counter and the random start add as QuantLib's
unsigned longs do under MSVC, in 32 bits, so their sum wraps at 2^32.
Constructors
HaltonRsg(int, long, bool, bool)
Initializes a new instance of the HaltonRsg class.
public HaltonRsg(int dimensionality, long seed, bool randomStart = true, bool randomShift = false)
Parameters
dimensionalityintThe dimension of each sequence, at least 1.
seedlongThe seed, in [1, 4294967295], of the random start and shift.
randomStartboolWhether each dimension starts at a random point of its sequence.
randomShiftboolWhether each dimension is shifted by a random amount, modulo 1.
Exceptions
- ArgumentOutOfRangeException
dimensionalityis below 1, orseedoutside [1, 4294967295].
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 generator's, into its own buffer, and the two change apart.
public HaltonRsg Clone()
Returns
- HaltonRsg
The copy.
LastSequence()
Gets the sequence the last draw gave.
public Sample<ReadOnlyMemory<double>> LastSequence()
Returns
- Sample<ReadOnlyMemory<double>>
The sequence, a view of the generator's buffer valid until its next draw, and its weight.
NextSequence()
Draws the next sequence, with weight 1.0.
public Sample<ReadOnlyMemory<double>> NextSequence()
Returns
- Sample<ReadOnlyMemory<double>>
The sequence, a view of the generator's buffer valid until its next draw, and its weight.
Explicit Interface Implementations
Create(int, long)
Builds a generator from a dimension and a seed, with QuantLib's defaults (a random start, no random shift), for generic code (ISeedableRsg<TSelf>).
static HaltonRsg Create(int dimension, long seed)
Parameters
Returns
- HaltonRsg
The generator.
Exceptions
- ArgumentOutOfRangeException
An argument is out of its range.