SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
OrnsteinUhlenbeckProcessEuler.java
1/*
2 * Class: OrnsteinUhlenbeckProcessEuler
3 * Description:
4 * Environment: Java
5 * Software: SSJ
6 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
7 * Organization: DIRO, Universite de Montreal
8 * @author
9 * @since
10 *
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 */
25package umontreal.ssj.stochprocess;
26
27import umontreal.ssj.rng.*;
28import umontreal.ssj.probdist.*;
29import umontreal.ssj.randvar.*;
30
45
53 public OrnsteinUhlenbeckProcessEuler(double x0, double alpha, double b, double sigma, RandomStream stream) {
54 this(x0, alpha, b, sigma, new NormalGen(stream));
55 }
56
62 public OrnsteinUhlenbeckProcessEuler(double x0, double alpha, double b, double sigma, NormalGen gen) {
63 super(x0, alpha, b, sigma, gen);
64 }
65
66 public double nextObservation() {
67 double xOld = path[observationIndex];
68 double x = xOld + (beta - xOld) * alphadt[observationIndex] + sigmasqrdt[observationIndex] * gen.nextDouble();
69 observationIndex++;
70 path[observationIndex] = x;
71 return x;
72 }
73
83 public double nextObservation(double nextTime) {
84 double previousTime = t[observationIndex];
85 double xOld = path[observationIndex];
86 observationIndex++;
87 t[observationIndex] = nextTime;
88 double dt = nextTime - previousTime;
89 double x = xOld + alpha * (beta - xOld) * dt + sigma * Math.sqrt(dt) * gen.nextDouble();
90 path[observationIndex] = x;
91 return x;
92 }
93
100 public double nextObservation(double x, double dt) {
101 x = x + alpha * (beta - x) * dt + sigma * Math.sqrt(dt) * gen.nextDouble();
102 return x;
103 }
104
111 public double[] generatePath() {
112 double x;
113 double xOld = x0;
114 for (int j = 0; j < d; j++) {
115 x = xOld + (beta - xOld) * alphadt[j] + sigmasqrdt[j] * gen.nextDouble();
116 path[j + 1] = x;
117 xOld = x;
118 }
119 observationIndex = d;
120 return path;
121 }
122
123 protected void initArrays(int d) {
124 double dt;
125 for (int j = 0; j < d; j++) {
126 dt = t[j + 1] - t[j];
127 alphadt[j] = alpha * (dt);
128 sigmasqrdt[j] = sigma * Math.sqrt(dt);
129 }
130 }
131}
This class implements methods for generating random variates from the normal distribution .
OrnsteinUhlenbeckProcessEuler(double x0, double alpha, double b, double sigma, RandomStream stream)
Constructor with parameters alpha, ,.
double[] generatePath()
Generates a sample path of the process at all observation times, which are provided in array t.
OrnsteinUhlenbeckProcessEuler(double x0, double alpha, double b, double sigma, NormalGen gen)
Here, the normal variate generator is specified directly instead of specifying the stream.
double nextObservation()
Generates and returns the next observation of the stochastic process.
double nextObservation(double x, double dt)
Generates and returns an observation of the process in dt time units, assuming that the process has v...
double nextObservation(double nextTime)
Generates and returns the next observation at time nextTime.
OrnsteinUhlenbeckProcess(double x0, double alpha, double b, double sigma, RandomStream stream)
Constructs a new OrnsteinUhlenbeckProcess with parameters.
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...