25package umontreal.ssj.stochprocess;
27import umontreal.ssj.rng.*;
28import umontreal.ssj.probdist.*;
29import umontreal.ssj.randvar.*;
59 protected double alpha, beta, sigma, nu;
61 protected double[] parc, parlam;
84 nu = 4.0 * b * alpha / (sigma * sigma);
86 stream = gen.getStream();
90 double xOld = path[observationIndex];
91 double lambda = xOld * parlam[observationIndex];
100 path[observationIndex] = x;
114 double previousTime = t[observationIndex];
115 double xOld = path[observationIndex];
117 t[observationIndex] = nextTime;
118 double dt = nextTime - previousTime;
120 path[observationIndex] = x;
131 double c = -Math.expm1(-alpha * dt) * sigma * sigma / (4.0 * alpha);
132 double lambda = x * Math.exp(-alpha * dt) / c;
148 for (j = 0; j < d; j++) {
149 lambda = xOld * parlam[j];
156 for (j = 0; j < d; j++) {
157 lambda = xOld * parlam[j];
164 for (j = 0; j < d; j++) {
165 lambda = xOld * parlam[j];
172 observationIndex = d;
184 gen.setStream(stream);
194 public void setParams(
double x0,
double alpha,
double b,
double sigma) {
199 nu = 4.0 * b * alpha / (sigma * sigma);
200 if (observationTimesSet)
208 gen.setStream(stream);
215 return gen.getStream();
248 protected void initArrays(
int d) {
250 for (
int j = 0; j < d; j++) {
251 dt = t[j + 1] - t[j];
252 c = -Math.expm1(-alpha * dt) * sigma * sigma / (4.0 * alpha);
254 parlam[j] = Math.exp(-alpha * dt) / c;
260 protected void init() {
262 parc =
new double[d];
263 parlam =
new double[d];
This class implements noncentral chi square random variate generators using the additive property of ...
double nextDouble()
Generates a random number from the continuous distribution contained in this object.
This class implements random variate generators for the noncentral chi square distribution with degr...
static double nextDouble(RandomStream s, double nu, double lambda)
Generates a new variate from the noncentral chi square distribution with nu = degrees of freedom and...
This class implements noncentral chi square random variate generators using Poisson and central chi s...
double nextDouble()
Generates a random number from the continuous distribution contained in this object.
ChiSquareNoncentralGen getGen()
Returns the noncentral chi-square random variate generator used.
CIRProcess(double x0, double alpha, double b, double sigma, ChiSquareNoncentralGen gen)
The noncentral chi-square variate generator gen is specified directly instead of specifying the strea...
void setParams(double x0, double alpha, double b, double sigma)
Resets the parameters , , and of the process.
CIRProcess(double x0, double alpha, double b, double sigma, RandomStream stream)
Constructs a new CIRProcess with parameters , , and initial value .
double[] generatePath()
Generates, returns, and saves the sample path .
double getB()
Returns the value of .
double[] generatePath(RandomStream stream)
Generates a sample path of the process at all observation times, which are provided in array t.
double nextObservation(double x, double dt)
Generates an observation of the process in dt time units, assuming that the process has value at the...
double nextObservation()
Generates and returns the next observation of the stochastic process.
RandomStream getStream()
Returns the random stream of the noncentral chi-square generator.
double getAlpha()
Returns the value of .
double getSigma()
Returns the value of .
double nextObservation(double nextTime)
Generates and returns the next observation at time , using the previous observation time defined ea...
void setStream(RandomStream stream)
Resets the random stream of the noncentral chi-square generator to 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...