1package umontreal.ssj.markovchainrqmc;
3import umontreal.ssj.stat.Tally;
4import umontreal.ssj.rng.*;
5import umontreal.ssj.util.Chrono;
6import umontreal.ssj.util.PrintfFormat;
7import umontreal.ssj.hups.*;
38 protected boolean stopped =
false;
75 public Object
clone() throws CloneNotSupportedException {
79 }
catch (CloneNotSupportedException e) {
80 System.err.println(
"This MarkovChain cannot be cloned");
98 this.numSteps = numSteps;
122 for (
int i = 0; i < n; i++) {
136 for (
int i = 0; i < n; i++) {
157 return simulMC(n, Integer.MAX_VALUE);
165 for (
int rep = 0; rep < m; ++rep) {
192 for (
int rep = 0; rep < m; rep++) {
204 simulRuns(n, numSteps, stream, statRuns);
205 StringBuffer sb =
new StringBuffer(
"----------------------------------------------" +
PrintfFormat.
NEWLINE);
210 return sb.toString();
220 StringBuffer sb =
new StringBuffer(
"----------------------------------------------" +
PrintfFormat.
NEWLINE);
225 return sb.toString();
233 simulRQMC(p, m, numSteps, rand, statReps);
235 StringBuffer sb =
new StringBuffer(
"----------------------------------------------" +
PrintfFormat.
NEWLINE);
242 return sb.toString();
253 StringBuffer sb =
new StringBuffer(
simulRQMCFormat(p, m, numSteps, rand, statReps));
256 return sb.toString();
264 StringBuffer sb =
new StringBuffer(
" Average value = ");
266 sb.append(
" Variance = ");
268 sb.append(
stat.formatCIStudent(0.9, 7));
269 return sb.toString();
277 StringBuffer sb =
new StringBuffer(
" Average value = ");
279 sb.append(
" Variance * numPoints = ");
281 sb.append(
stat.formatCIStudent(0.9, 7));
282 return sb.toString();
This abstract class represents a general point set.
void randomize(PointSetRandomization rand)
Randomizes this point set using the given rand.
PointSetIterator iterator()
Constructs and returns a point set iterator.
int getNumPoints()
Returns the number of points.
String toString()
Formats a string that contains information about the point set.
This class defines a generic Markov chain and provides basic tools to simulate it for a given number ...
boolean hasStopped()
Tells if the chain has stopped.
abstract void nextStep(RandomStream stream)
Simulates one more step of the chain, from its current state, using stream for the randomness.
abstract void initialState()
Sets the Markov chain to its (deterministic) initial state and initializes the collectors for the per...
void simulRepMC(int n, int numSteps, int m, Tally t)
Perform n runs and compute the average, reapeat m times and return the stats in t.
String formatResultsRQMC(Tally stat, int numPoints)
Returns a string containing the mean, the variance multiplied by numPoints, and a 90% confidence inte...
abstract double getPerformance()
Returns the performance measure (total or average cost or gain) so far, for the current simulation ru...
String simulRQMCFormat(PointSet p, int m, int numSteps, PointSetRandomization rand, Tally statReps)
Same as simulRQMC but also returns the results as a formatted string.
void simulSteps(RandomStream stream)
Starts a new simulation run and simulates until the stopping time is reached, using the given stream.
double simulMC(int n)
Perform n runs, each one until the chain stops.
String simulRunsFormat(int n, int numSteps, RandomStream stream, Tally statRuns)
Same as simulRuns but also returns the results as a formatted string.
double simulMC(int n, int numSteps)
Perform n simulation runs of the chain, each for numSteps steps, and returns average.
void simulRepMC(int n, int m, Tally t)
Same as previous one, but run the chains until they stop.
void simulSteps(int numSteps, RandomStream stream)
Starts a new simulation run and simulates numSteps steps of the Markov chain or until the chain stops...
void simulRQMC(PointSet p, int m, int numSteps, PointSetRandomization rand, Tally statReps)
Performs m independent replicates of simulation runs of the chain using a RQMC point set,...
String formatResults(Tally stat)
Returns a string containing the mean, the variance, and a 90% confidence interval for stat.
String simulRunsWithSubstreamsFormat(int n, int numSteps, RandomStream stream, Tally statRuns)
Same as simulRunsWithSubstreams but also returns the results as a formatted string.
void simulRunsWithSubstreams(int n, int numSteps, RandomStream stream, Tally statRuns)
Same as simulRuns, except that the stream is first reset to its initial seed and then reset to the fi...
void simulRuns(int n, int numSteps, RandomStream stream, Tally statRuns)
Performs n simulation runs of the chain, for numSteps steps per run, using the given stream.
Object clone()
Returns a clone of the chain.
String testImprovementRQMCFormat(PointSet p, int m, int numSteps, PointSetRandomization rand, double varMC, Tally statReps)
Similar to simulRQMCFormat, but also gives the variance improvement factor with respect to MC.
Extends the abstract class RandomStreamBase by using as a backbone (or main) generator the combined m...
double average()
Returns the average value of the observations since the last initialization.
double variance()
Returns the sample variance of the observations since the last initialization.
void init()
Initializes the statistical collector.
void add(double x)
Gives a new observation x to the statistical collector.
The Chrono class extends the umontreal.ssj.util.AbstractChrono class and computes the CPU time for th...
static Chrono createForSingleThread()
Creates a Chrono instance adapted for a program using a single thread.
This interface is for a randomization that can be used to randomize a umontreal.ssj....
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...
void resetNextSubstream()
Reinitializes the stream to the beginning of its next substream:
void resetStartStream()
Reinitializes the stream to its initial state : and are set to .
Tools for Collecting Statistics and computing estimators and confidence intervals.