25package umontreal.ssj.stochprocess;
27import umontreal.ssj.rng.*;
28import umontreal.ssj.probdist.*;
29import umontreal.ssj.randvar.*;
55 protected double alpha, beta, sigma;
57 protected double[] badt, alphadt, sigmasqrdt;
67 this(x0, alpha, b, sigma,
new NormalGen(stream));
84 double xOld = path[observationIndex];
85 double x = badt[observationIndex] + xOld * alphadt[observationIndex]
86 + sigmasqrdt[observationIndex] * gen.nextDouble();
88 path[observationIndex] = x;
103 double previousTime = t[observationIndex];
104 double xOld = path[observationIndex];
106 t[observationIndex] = nextTime;
107 double dt = nextTime - previousTime;
108 double tem = Math.exp(-alpha * dt);
109 double tem1 = -Math.expm1(-alpha * dt);
110 double x = tem * xOld + beta * tem1 + sigma * Math.sqrt(tem1 * (1.0 + tem) / (2.0 * alpha)) * gen.nextDouble();
111 path[observationIndex] = x;
122 double tem = Math.exp(-alpha * dt);
123 double tem1 = -Math.expm1(-alpha * dt);
124 x = tem * x + beta * tem1 + sigma * Math.sqrt(tem1 * (1.0 + tem) / (2.0 * alpha)) * gen.nextDouble();
131 for (
int j = 0; j < d; j++) {
132 x = badt[j] + xOld * alphadt[j] + sigmasqrdt[j] * gen.nextDouble();
136 observationIndex = d;
148 gen.setStream(stream);
159 public void setParams(
double x0,
double alpha,
double b,
double sigma) {
164 if (observationTimesSet)
172 gen.setStream(stream);
179 return gen.getStream();
211 protected void initArrays(
int d) {
212 double dt, tem, tem1;
213 for (
int j = 0; j < d; j++) {
214 dt = t[j + 1] - t[j];
215 tem = Math.exp(-alpha * dt);
216 tem1 = -Math.expm1(-alpha * dt);
217 badt[j] = beta * tem1;
219 sigmasqrdt[j] = sigma * Math.sqrt(tem1 * (1.0 + tem) / (2.0 * alpha));
225 protected void init() {
227 badt =
new double[d];
228 alphadt =
new double[d];
229 sigmasqrdt =
new double[d];
This class implements methods for generating random variates from the normal distribution .
RandomStream getStream()
Returns the random stream of the normal generator.
double getB()
Returns the value of .
OrnsteinUhlenbeckProcess(double x0, double alpha, double b, double sigma, NormalGen gen)
Here, the normal variate generator is specified directly instead of specifying the stream.
double getSigma()
Returns the value of .
double[] generatePath()
Generates, returns, and saves the sample path .
double nextObservation()
Generates and returns the next observation of the stochastic process.
OrnsteinUhlenbeckProcess(double x0, double alpha, double b, double sigma, RandomStream stream)
Constructs a new OrnsteinUhlenbeckProcess with parameters.
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...
void setParams(double x0, double alpha, double b, double sigma)
Resets the parameters x0, alpha,.
NormalGen getGen()
Returns the normal random variate generator used.
double nextObservation(double nextTime)
Generates and returns the next observation at time nextTime, using the previous observation time de...
double getAlpha()
Returns the value of .
void setStream(RandomStream stream)
Resets the random stream of the normal 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...