SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
MarkovChainDouble.java
1package umontreal.ssj.markovchainrqmc;
2
3import umontreal.ssj.rng.*;
4import umontreal.ssj.stat.Tally;
5
31public abstract class MarkovChainDouble extends MarkovChainComparable {
32
33 protected double state = 0; // State of this chain.
34 protected int step = 0; // Current step.
35 protected double perf = 0;
36
40
44 public abstract double initialStateDouble();
45
46 public void initialState() {
47 step = 0;
48 state = initialStateDouble();
49 stopped = false;
50 }
51
58 public abstract double nextStepDouble(int step, double s, RandomStream stream);
59
60 public void nextStep(RandomStream stream) {
61 state = nextStepDouble(step, state, stream);
62 step++;
63 }
64
69 public abstract double getPerformanceDouble(double state, int numSteps);
70
74
78
83 public double getPerformance(int numSteps) {
84 return getPerformanceDouble(state, numSteps);
85 }
86
90 public double getPerformance() {
91 return perf;
92 }
93
97 public boolean hasStopped() {
98 return state == Double.POSITIVE_INFINITY;
99 }
100
101 public int getStateDimension() {
102 return 1;
103 }
104
105 public int compareTo(MarkovChainComparable other, int i) {
106 double os = ((MarkovChainDouble) other).state;
107 return (state < os ? -1 : (state > os ? 1 : 0));
108 }
109
116 public double simulStepsDouble(int numSteps, RandomStream stream) {
117 initialState();
118 for (step = 0; step < numSteps && !hasStopped(); ++step) {
119 state = nextStepDouble(step, state, stream);
120 }
121 return state;
122 }
123
129 public void simulRunsWithSubstreams(int n, int numSteps, RandomStream stream, Tally statRuns) {
130 statRuns.init();
131 stream.resetStartStream();
132 for (int i = 0; i < n; i++) {
133 simulStepsDouble(numSteps, stream);
134 statRuns.add(getPerformanceDouble(state, numSteps));
135 stream.resetNextSubstream();
136 }
137 }
138
139}
140
A subclass of MarkovChain for which there is a total ordering between the states, induced by the impl...
A special kind of Markov chain whose state space is a subset of the real numbers.
double simulStepsDouble(int numSteps, RandomStream stream)
After invoking initialStateDouble, starts a new simulation run, simulates numSteps steps of the Marko...
void initialState()
Sets the Markov chain to its (deterministic) initial state and initializes the collectors for the per...
double getPerformance()
Returns the value of perf which is computed when a chain stops.
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...
double getPerformance(int numSteps)
Returns the performance mesure associated with current state, which may depend on the number of steps...
abstract double nextStepDouble(int step, double s, RandomStream stream)
Simulates one step of the chain, from state s, using stream for the randomness, assuming we are at st...
abstract double getPerformanceDouble(double state, int numSteps)
Returns the performance measure associated with state state, which may depend on the number of steps ...
void nextStep(RandomStream stream)
Simulates one more step of the chain, from its current state, using stream for the randomness.
int getStateDimension()
Returns the dimension of the state.
boolean hasStopped()
Indicates if the chain has stopped.
abstract double initialStateDouble()
Returns the initial (deterministic) state.
A subclass of StatProbe.
Definition Tally.java:47
void init()
Initializes the statistical collector.
Definition Tally.java:91
void add(double x)
Gives a new observation x to the statistical collector.
Definition Tally.java:109
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 .