SSJ
3.3.1
Stochastic Simulation in Java
|
This class provides tools to simulate an array of MarkovChainComparable objects with the array-RQMC method of [139], [141] . More...
Public Member Functions | |
ArrayOfComparableChains (T baseChain) | |
Creates an array of the comparable chain baseChain . More... | |
ArrayOfComparableChains (T baseChain, PointSetRandomization rand, MultiDimSort sort) | |
Creates an array of the comparable chain baseChain . More... | |
void | makeCopies (int n) |
Creates n copies (clones) of the chain baseChain and puts them in an array, ready for the array RQMC simulation. | |
void | initialStates () |
Initializes the n copies (clones) of the chain baseChain to their initial state by calling initialState() on each chain. | |
int | getN () |
Returns the number n of chains. | |
T [] | getChains () |
Returns the underlying array of n MarkovChainComparable. | |
void | setRandomization (PointSetRandomization rand) |
Sets the internal umontreal.ssj.hups.PointSetRandomization to rand . | |
PointSetRandomization | getRandomization () |
Returns the internal umontreal.ssj.hups.PointSetRandomization. | |
void | setSort (MultiDimSort sort) |
Sets the internal umontreal.ssj.util.MultiDimSort to sort . | |
MultiDimSort | getSort () |
Returns the saved umontreal.ssj.util.MultiDimSort. | |
int | simulOneStepArrayRQMC (PointSet p, PointSetRandomization rand, MultiDimSort sort, int sortCoordPts) |
Randomized the point set p and Simulates the \(n\) copies of the chain, one step for each copy, using umontreal.ssj.hups.PointSet p , where \(n\) is the current number of copies (clones) of the chain and is assumed to equal the number of points in p . More... | |
int | simulOneStepArrayRQMC (PointSet p) |
This version uses the preselected randomization and sort, with sortCoordPts = 0 . | |
double | simulArrayRQMC (PointSet p, PointSetRandomization rand, MultiDimSort sort, int sortCoordPts, int numSteps) |
Simulates the \(n\) copies of the chain, numSteps steps for each copy, using umontreal.ssj.hups.PointSet p , where \(n\) is the current number of copies (clones) of the chain and is assumed to equal the number of points in p . More... | |
double | simulArrayRQMC (PointSet p, PointSetRandomization rand, MultiDimSort sort, int numSteps) |
This version assumes that sortCoordPts = 0 , so that there is no need to sort the points at each step. | |
double | simulArrayRQMC (PointSet p, int numSteps) |
This version assumes that sortCoordPts = 0 and uses the preset randomization and sort for the chains. | |
double [] | getPerformances () |
Returns the vector for performances for the \(n\) chains. | |
double | calcMeanPerf () |
Computes and returns the mean performance of the \(n\) chains. | |
void | simulReplicatesArrayRQMC (PointSet p, PointSetRandomization rand, MultiDimSort sort, int sortCoordPts, int numSteps, int m, Tally statReps) |
Performs m independent replications of an array-RQMC simulation as in simulArrayRQMC . More... | |
String | simulReplicatesArrayRQMCFormat (PointSet p, PointSetRandomization rand, MultiDimSort sort, int sortCoordPts, int numSteps, int m, Tally statReps) |
Performs m independent replications of an array-RQMC simulation as in simulFormatArrayRQMC . More... | |
String | varianceImprovementFormat (double varRQMC, double varMC) |
Returns a string that reports the the ratio of MC variance per run varMC over the RQMC variance per run varRQMC . | |
String | testVarianceRateFormat (PointSet[] pointSets, PointSetRandomization rand, MultiDimSort sort, int sortCoordPts, int numSteps, int m, double varMC, String filenamePlot, String methodLabel) |
Performs an experiment to estimate the convergence rate of the RQMC variance as a function of \(n\), by invoking #simulReplicatesArrayRQMC(r) epeatedly with a given array of point sets of different sizes \(n\). More... | |
void | sortNotStoppedChains (MultiDimSort sort) |
Sorts the chains that have not stopped yet using the stored umontreal.ssj.util.MultiDimSort. More... | |
void | sortChains () |
Sorts the chains using the stored umontreal.ssj.util.MultiDimSort. | |
String | formatTime (double time) |
double | slope (double[] x, double[] y, int n) |
Protected Attributes | |
T | baseChain |
int | n |
T [] | chains |
double [] | performances |
PointSetRandomization | randomization |
MultiDimSort< T > | savedSort |
int | sortCoordPts = 0 |
This class provides tools to simulate an array of MarkovChainComparable objects with the array-RQMC method of [139], [141] .
It offers tools to construct the array of chains, simulate with array-RQMC for one step or multiple steps, perform experiments, and report some results.
At each step, the \(n\) states (which correspond to the \(n\) copies of the chain) are sorted in \(\ell\) dimensions (usually the dimension of the state). If \(\ell=1\), this is an ordinary sort. If \(\ell> 1\), they are sorted using a umontreal.ssj.util.MultiDimSort, which in general can sort umontreal.ssj.util.MultiDimComparable objects. As a special case, they can also be sorted using a umontreal.ssj.util.MultiDimSort01 type of sort. Some of these sorts effectively map the chain states to the one-dimensional interval \((0,1)\). For example, the sorts based on a Hilbert curve, such as umontreal.ssj.util.HilbertCurveSort, do that. In that case, we put \(\ell’=1\), otherwise \(\ell’=\ell\).
To move the chains ahead, we use an \((\ell’+d)\)-dimensional RQMC umontreal.ssj.hups.PointSet. The first \(\ell’\) coordinates are used to sort the points to map them to the (sorted) chains. In some cases, when \(\ell’=1\), the first coordinate of the points is not stored explicitly; the points are already sorted by a first coordinate which is only implicit (it serves to enumerate the points). This is what happens for a Sobol’ sequence, or a umontreal.ssj.hups.KorobovLattice for which the first coordinate is dropped, for example. Only \(d\) coordinates are produced with those point sets and have to be randomized. In the other cases, the points must be sorted by their first \(\ell’\) coordinates.
At each step the umontreal.ssj.hups.PointSet is randomized by using a umontreal.ssj.hups.PointSetRandomization. There are types of point sets for which only the last \(d\) coordinates have to be randomized (e.g., digital nets and lattice rules) and others for which all \(\ell’ + d\) coordinates must be randomized (e.g., a stratified sample).
When applying the array-RQMC method, the number of point coordinates used explicitly to sort the points and match the chains (which is either \(\ell’\) or 0) is passed in a variable named sortCoord
, and the number of these coordinates that must be randomized at each step is passed in a variable named sortCoordRand
. In the case where \(\ell’=1\) and the first coordinate is only implicit, both should be 0. In the case where \(\ell’ > 1\) but only the last \(d\) coordinates have to be randomized at each step, one would put sortCoord
to \(\ell’\) and sortCoordRand
to 0.
ArrayOfComparableChains | ( | T | baseChain | ) |
Creates an array of the comparable chain baseChain
.
The method makeCopies(int) must be called afterward to make the actual copies of the chain.
ArrayOfComparableChains | ( | T | baseChain, |
PointSetRandomization | rand, | ||
MultiDimSort | sort | ||
) |
Creates an array of the comparable chain baseChain
.
The method makeCopies(int) must be called to make the copies. rand
will be used to randomize the point sets in the simulations. sort
will be used to sort the chains.
double simulArrayRQMC | ( | PointSet | p, |
PointSetRandomization | rand, | ||
MultiDimSort | sort, | ||
int | sortCoordPts, | ||
int | numSteps | ||
) |
Simulates the \(n\) copies of the chain, numSteps
steps for each copy, using umontreal.ssj.hups.PointSet p
, where \(n\) is the current number of copies (clones) of the chain and is assumed to equal the number of points in p
.
At each step, the points are randomized using rand
. All coordinates are randomized. If sortCoordPts
\(>0\), the points are also sorted explicitly based on their first sortCoordPts
coordinates, at each step, after they are randomized. In that case, p
must implement the umontreal.ssj.util.MultiDim01 interface. If the coordinates used for the sort do not have to be randomized at each step and the points do not have to be sorted again, one should remove these coordinates before invoking this method and use sortCoordPts=0
. In this case, the points must be sorted before invoking this method. The class umontreal.ssj.hups.SortedAndCutPointSet can be useful for this. The dimension of p
must be at least as large as sortCoordPts
\(+\) the number of uniforms required to simulate one step of the chain. The method returns the average performance per run. An array that contains the performance for each run can also be obtained via getPerformances()(.)
int simulOneStepArrayRQMC | ( | PointSet | p, |
PointSetRandomization | rand, | ||
MultiDimSort | sort, | ||
int | sortCoordPts | ||
) |
Randomized the point set p
and Simulates the \(n\) copies of the chain, one step for each copy, using umontreal.ssj.hups.PointSet p
, where \(n\) is the current number of copies (clones) of the chain and is assumed to equal the number of points in p
.
The points are randomized before the simulation using the stored umontreal.ssj.hups.PointSetRandomization. If sortCoordPts
\(>0\), the points are also sorted explicitly based on their first sortCoordPts
coordinates, at each step, after they are randomized. In that case, p
must implement the umontreal.ssj.util.MultiDim01 interface. The dimension of p
must be at least as large as sortCoordPts
\(+\) the number of uniforms required to simulate one step of the chain. Returns the number of chains that have not stopped yet.
void simulReplicatesArrayRQMC | ( | PointSet | p, |
PointSetRandomization | rand, | ||
MultiDimSort | sort, | ||
int | sortCoordPts, | ||
int | numSteps, | ||
int | m, | ||
Tally | statReps | ||
) |
Performs m
independent replications of an array-RQMC simulation as in simulArrayRQMC
.
The statistics on the m
corresponding averages are collected in statReps
.
String simulReplicatesArrayRQMCFormat | ( | PointSet | p, |
PointSetRandomization | rand, | ||
MultiDimSort | sort, | ||
int | sortCoordPts, | ||
int | numSteps, | ||
int | m, | ||
Tally | statReps | ||
) |
Performs m
independent replications of an array-RQMC simulation as in simulFormatArrayRQMC
.
The statistics on the m
corresponding averages are collected in statReps
and the results are also returned in a string.
void sortNotStoppedChains | ( | MultiDimSort | sort | ) |
Sorts the chains that have not stopped yet using the stored umontreal.ssj.util.MultiDimSort.
All the stopped chains are placed at the end, then the chains that have not stopped are sorted.
String testVarianceRateFormat | ( | PointSet [] | pointSets, |
PointSetRandomization | rand, | ||
MultiDimSort | sort, | ||
int | sortCoordPts, | ||
int | numSteps, | ||
int | m, | ||
double | varMC, | ||
String | filenamePlot, | ||
String | methodLabel | ||
) |
Performs an experiment to estimate the convergence rate of the RQMC variance as a function of \(n\), by invoking #simulReplicatesArrayRQMC(r) epeatedly with a given array of point sets of different sizes \(n\).
Returns a string that reports the mean, variance, and variance reduction factor (VRF) with respect to MC for each point set, and the estimated convergence rate of the RQMC variance as a function of \(n\). Assumes that varMC
is the variance per run for MC. The string methodLabel
should be a brief descriptor of the method (e.g., the type of point set, type of randomization, and type of sort). If the string filenamePlot != null
, then the method also creates a .tex
file with that name that contains a plot in log scale of the variance vs \(n\).