Class SobolRsg
- java.lang.Object
-
- org.jquantlib.math.randomnumbers.SobolRsg
-
- All Implemented Interfaces:
- UniformRandomSequenceGenerator
public class SobolRsg extends java.lang.Object implements UniformRandomSequenceGenerator
Sobol low-discrepancy sequence generatorA Gray code counter and bitwise operations are used for very fast sequence generation.
The implementation relies on primitive polynomials modulo two from the book "Monte Carlo Methods in Finance" by Peter Jaeckel.
21 200 primitive polynomials modulo two are provided in QuantLib. Jaeckel has calculated 8 129 334 polynomials: if you need that many dimensions you can replace the primitivepolynomials.c file included in QuantLib with the one provided in the CD of the "Monte Carlo Methods in Finance" book.
The choice of initialization numbers (also know as free direction integers) is crucial for the homogeneity properties of the sequence. Sobol defines two homogeneity properties: Property A and Property A'.
The unit initialization numbers suggested in "Numerical Recipes in C", 2nd edition, by Press, Teukolsky, Vetterling, and Flannery (section 7.7) fail the test for Property A even for low dimensions.
Bratley and Fox published coefficients of the free direction integers up to dimension 40, crediting unpublished work of Sobol' and Levitan. See Bratley, P., Fox, B.L. (1988) "Algorithm 659: Implementing Sobol's quasirandom sequence generator," ACM Transactions on Mathematical Software 14:88-100. These values satisfy Property A for d<=20 and d = 23, 31, 33, 34, 37; Property A' holds for d<=6.
Jaeckel provides in his book (section 8.3) initialization numbers up to dimension 32. Coefficients for d<=8 are the same as in Bradley-Fox, so Property A' holds for d<=6 but Property A holds for d<=32.
The implementation of Lemieux, Cieslak, and Luttmer includes coefficients of the free direction integers up to dimension 360. Coefficients for d<=40 are the same as in Bradley-Fox. For dimension 40
For more info on Sobol' sequences see also "Monte Carlo Methods in Financial Engineering," by P. Glasserman, 2004, Springer, section 5.2.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classSobolRsg.DirectionIntegers
-
Constructor Summary
Constructors Constructor and Description SobolRsg(int dimensionality)dimensionality must be <= PPMT_MAX_DIMSobolRsg(int dimensionality, long seed)SobolRsg(int dimensionality, long seed, SobolRsg.DirectionIntegers direction)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description intdimension()Sample<double[]>lastSequence()long[]nextInt32Sequence()Once JVM does not support unsigned fixed arithmetic, we use 64bit variables as containers for 32bit values in order to reduce the complexity and performance overhead of certain fixed arithmetic operations.Sample<double[]>nextSequence()
-
-
-
Constructor Detail
-
SobolRsg
public SobolRsg(int dimensionality)
dimensionality must be <= PPMT_MAX_DIM
-
SobolRsg
public SobolRsg(int dimensionality, long seed)
-
SobolRsg
public SobolRsg(int dimensionality, long seed, SobolRsg.DirectionIntegers direction)
-
-
Method Detail
-
dimension
public int dimension()
- Specified by:
dimensionin interfaceUniformRandomSequenceGenerator
-
nextInt32Sequence
public final long[] nextInt32Sequence()
Description copied from interface:UniformRandomSequenceGeneratorOnce JVM does not support unsigned fixed arithmetic, we use 64bit variables as containers for 32bit values in order to reduce the complexity and performance overhead of certain fixed arithmetic operations.From the user's perspective, it's easier to understand that a certain
longvariable contains values from 0 to 2^32 than understand that a certainintvariable contains negative values that should be converted to it's two's complement and extended to alongvariable before use.- Specified by:
nextInt32Sequencein interfaceUniformRandomSequenceGenerator- Returns:
- an array of unsigned 32bit wide numbers encapsulated in a 64bit containers
- See Also:
- Bug 4504839, Java and Unsigned Types, Two's complement
-
nextSequence
public final Sample<double[]> nextSequence()
- Specified by:
nextSequencein interfaceUniformRandomSequenceGenerator
-
lastSequence
public final Sample<double[]> lastSequence()
- Specified by:
lastSequencein interfaceUniformRandomSequenceGenerator
-
-
DataMelt 3.0 © DataMelt by jWork.ORG