25package umontreal.ssj.stochprocess;
27import umontreal.ssj.rng.*;
28import umontreal.ssj.probdist.*;
29import umontreal.ssj.randvar.*;
45 protected double alpha, beta, sigma;
47 protected double[] alphadt, sigmasqrdt;
72 double xOld = path[observationIndex];
74 x = xOld + (beta - xOld) * alphadt[observationIndex]
75 + sigmasqrdt[observationIndex] * Math.sqrt(xOld) * gen.nextDouble();
78 path[observationIndex] = x;
80 path[observationIndex] = 0.;
95 double previousTime = t[observationIndex];
96 double xOld = path[observationIndex];
98 t[observationIndex] = nextTime;
99 double dt = nextTime - previousTime;
100 double x = xOld + alpha * (beta - xOld) * dt + sigma * Math.sqrt(dt * xOld) * gen.nextDouble();
102 path[observationIndex] = x;
104 path[observationIndex] = 0.;
115 x = x + alpha * (beta - x) * dt + sigma * Math.sqrt(dt * x) * gen.nextDouble();
124 for (
int j = 0; j < d; j++) {
125 x = xOld + (beta - xOld) * alphadt[j] + sigmasqrdt[j] * Math.sqrt(xOld) * gen.nextDouble();
131 observationIndex = d;
143 gen.setStream(stream);
154 public void setParams(
double x0,
double alpha,
double b,
double sigma) {
159 if (observationTimesSet)
167 gen.setStream(stream);
174 return gen.getStream();
208 protected void init() {
210 alphadt =
new double[d];
211 sigmasqrdt =
new double[d];
213 for (
int j = 0; j < d; j++) {
214 dt = t[j + 1] - t[j];
215 alphadt[j] = alpha * (dt);
216 sigmasqrdt[j] = sigma * Math.sqrt(dt);
Extends the class ContinuousDistribution for the normal distribution (e.g., tjoh95a (page 80)).
This class implements methods for generating random variates from the normal distribution .
void setStream(RandomStream stream)
Resets the random stream of the normal generator to stream.
double getSigma()
Returns the value of .
double getB()
Returns the value of .
void setParams(double x0, double alpha, double b, double sigma)
Resets the parameters x0, alpha,.
double[] generatePath()
Generates, returns, and saves the sample path .
double nextObservation(double x, double dt)
Generates an observation of the process in dt time units, assuming that the process has value at the...
RandomStream getStream()
Returns the random stream of the normal generator.
double[] generatePath(RandomStream stream)
Generates a sample path of the process at all observation times, which are provided in array t.
CIRProcessEuler(double x0, double alpha, double b, double sigma, RandomStream stream)
Constructs a new CIRProcessEuler with parameters alpha, , sigma and initial value x0.
NormalGen getGen()
Returns the normal random variate generator used.
double nextObservation()
Generates and returns the next observation of the stochastic process.
double getAlpha()
Returns the value of .
double nextObservation(double nextTime)
Generates and returns the next observation at time nextTime, using the previous observation time de...
CIRProcessEuler(double x0, double alpha, double b, double sigma, NormalGen gen)
The normal variate generator gen is specified directly instead of specifying the stream.
Abstract base class for a stochastic process sampled (or observed) at a finite number of time points...
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...