1package umontreal.ssj.markovchainrqmc;
3import umontreal.ssj.stat.*;
4import umontreal.ssj.rng.*;
5import umontreal.ssj.hups.*;
6import umontreal.ssj.util.*;
7import umontreal.ssj.util.multidimsort.*;
9import java.util.Arrays;
35 protected double[] state;
36 protected double[] perfState;
44 this.baseChain = baseChain;
59 state =
new double[n];
60 perfState =
new double[n];
70 System.out.println(
"WARNING : number of chains modified" +
" to fit size of S in setStatesDouble(S)");
72 for (
int i = 0; i < n; i++) {
88 Arrays.fill(state, baseChain.initialStateDouble());
89 Arrays.fill(perfState, 0.0);
103 boolean allStopped =
true;
107 for (
int i = 0; i < n; i++) {
108 if (state[i] == Double.POSITIVE_INFINITY)
110 state[i] = baseChain.nextStepDouble(step, state[i], stream);
112 if (state[i] == Double.POSITIVE_INFINITY) {
113 perfState[i] = baseChain.getPerformance();
115 perfState[i] = baseChain.getPerformanceDouble(state[i], step);
116 allStopped = allStopped && state[i] == Double.POSITIVE_INFINITY;
134 boolean allStopped =
false;
137 for (
int step = 0; step < numSteps && !allStopped; step++) {
148 double sumPerf = 0.0;
149 for (
int i = 0; i < n; ++i) {
150 sumPerf += perfState[i];
166 StringBuffer sb =
new StringBuffer(baseChain.toString());
167 sb.append(
"***************************************************************" +
PrintfFormat.
NEWLINE);
168 for (
int i = 0; i < n; ++i)
170 sb.append(
"PrintfFormat.NEWLINE");
171 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.
This class implements a umontreal.ssj.hups.PointSetRandomization.
ArrayOfComparableChains(T baseChain)
Creates an array of the comparable chain baseChain.
double simulArrayRQMC(PointSet p, int numSteps)
Simulates the copies of the chain, numSteps steps for each copy, using point set p,...
ArrayOfDoubleChains(MarkovChainDouble baseChain)
Same as ArrayOfDoubleChains(baseChain, new RandomShift(new MRG32k3a())).
void initStatesDouble()
Initializes the states of the n copies of the base chain.
boolean simulOneStepArrayRQMC(int step, PointSet p)
Simulate one step for the n copies of the base chain, assuming that we are at step step.
double calcMeanPerf()
Computes and returns the mean performance of the chains.
ArrayOfDoubleChains(MarkovChainDouble baseChain, PointSetRandomization rand)
Creates a virtual array for the chain baseChain.
double[] getStatesDouble()
Returns the array containing the states of the n chains.
void setStatesDouble(double[] S)
Sets the states of the n copies of the base chain to S.
String toString()
Creates a String with the states.
void sortChains()
Sorts the arrays containing the states of the chains.
void makeCopies(int n)
Creates the vector of states for n copies of the base chain.
A special kind of Markov chain whose state space is a subset of the real numbers.
Extends the abstract class RandomStreamBase by using as a backbone (or main) generator the combined m...
This class implements a MultiDimSortComparable that simply sorts the objects according to a given sor...
This is the interface for iterators that permit one to go through the points of a PointSet and the su...
This interface is for a randomization that can be used to randomize a umontreal.ssj....
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 .