SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
VarianceGammaProcess.java
1/*
2 * Class: VarianceGammaProcess
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 2004
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
62public class VarianceGammaProcess extends StochasticProcess {
63
64 protected GammaProcess randomTime; // For the transformed time method
65 protected BrownianMotion BM;
66
67 protected double theta, sigma, nu;
68
69 public VarianceGammaProcess() {
70 }
71
79 public VarianceGammaProcess(double s0, double theta, double sigma, double nu, RandomStream stream) {
80 this(s0, new BrownianMotion(s0, theta, sigma, stream), new GammaProcess(0.0, 1.0, nu, stream));
81 }
82
94 public VarianceGammaProcess(double s0, BrownianMotion BM, GammaProcess Gamma) {
95 this.BM = BM;
96 Gamma.setParams(0.0, 1.0, Gamma.getNu()); // forces the average of the GammaProcess
97 randomTime = Gamma; // to be 1.0 and the initial value to be 0.0
98 setParams(s0, BM.getMu(), BM.getSigma(), Gamma.getNu());
99 }
100
109 public double nextObservation() {
110 // We first generate w, then verify what its new counter value is
111 // This is necessary to be general enough to handle bridge sampling
112 double nextBM = BM.nextObservation(randomTime.nextObservation());
113 observationIndex = BM.getCurrentObservationIndex();
114 path[observationIndex] = nextBM;
115 observationCounter++;
116 return nextBM;
117 }
118
126 public double[] generatePath() {
127 BM.setObservationTimes(randomTime.generatePath(), d);
128 path = BM.generatePath();
129 observationIndex = d;
130 observationCounter = d;
131 return path;
132 }
133
145 public double[] generatePath(double[] uniform01) {
146 int dd = uniform01.length;
147 int d = dd / 2;
148
149 if (dd % 2 != 0) {
150 throw new IllegalArgumentException("The Array uniform01 must have a even length");
151 }
152
153 double[] QMCpointsGP = new double[d];
154 double[] QMCpointsBM = new double[d];
155
156 for (int i = 0; i < d; i++) {
157 QMCpointsGP[i] = uniform01[2 * i]; // the odd numbers for the gamma process
158 QMCpointsBM[i] = uniform01[2 * i + 1]; // and the even for the BM process
159 }
160 BM.setObservationTimes(randomTime.generatePath(QMCpointsGP), d);
161
162 path = BM.generatePath(QMCpointsBM);
163 observationIndex = d;
164 observationCounter = d;
165 return path;
166 }
167
174 public void resetStartProcess() {
175 observationIndex = 0;
176 observationCounter = 0;
177 BM.resetStartProcess();
178 randomTime.resetStartProcess();
179 }
180
188 public void setParams(double s0, double theta, double sigma, double nu) {
189 this.x0 = s0;
190 this.theta = theta;
191 this.sigma = sigma;
192 this.nu = nu;
193 if (observationTimesSet)
194 init(); // Otherwise no need to.
195 }
196
200 public double getTheta() {
201 return theta;
202 }
203
207 public double getSigma() {
208 return sigma;
209 }
210
214 public double getNu() {
215 return nu;
216 }
217
218 protected void init() {
219 super.init();
220 if (observationTimesSet) {
221 randomTime.setObservationTimes(t, d);
222 randomTime.x0 = t[0];
223 }
224 }
225
231 public void setObservationTimes(double t[], int d) {
232 super.setObservationTimes(t, d); // sets the observation times of the GammaProcess by
233 } // calling init()
234
242 public void setStream(RandomStream stream) {
243 BM.setStream(stream);
244 }
245
251 return BM.getStream();
252 }
253
258 return BM;
259 }
260
265 return randomTime;
266 }
267
268}
This class represents a Brownian motion process , sampled at times .
This class represents a gamma process fmad98a  (page 82) with mean parameter.
void setParams(double s0, double mu, double nu)
Sets the parameters , and of the process.
double getNu()
Returns the value of the parameter .
Abstract base class for a stochastic process sampled (or observed) at a finite number of time points...
void setObservationTimes(double[] T, int d)
Sets the observation times of the process to a copy of T, with.
double getSigma()
Returns the value of the parameter .
VarianceGammaProcess(double s0, double theta, double sigma, double nu, RandomStream stream)
Constructs a new VarianceGammaProcess with parameters , , and initial value .
BrownianMotion getBrownianMotion()
Returns a reference to the inner BrownianMotion.
void resetStartProcess()
Resets the observation index and counter to 0 and applies the resetStartProcess method to the Brownia...
RandomStream getStream()
Returns the random stream of the BrownianMotion process, which should be the same as for the GammaPro...
GammaProcess getGammaProcess()
Returns a reference to the inner GammaProcess.
void setParams(double s0, double theta, double sigma, double nu)
Sets the parameters s0, theta,.
double nextObservation()
Generates the observation for the next time.
double[] generatePath(double[] uniform01)
Similar to the usual generatePath(), but here the uniform random numbers used for the simulation must...
double[] generatePath()
Generates and returns the path.
VarianceGammaProcess(double s0, BrownianMotion BM, GammaProcess Gamma)
Constructs a new VarianceGammaProcess.
double getTheta()
Returns the value of the parameter .
void setStream(RandomStream stream)
Resets the umontreal.ssj.rng.RandomStream ’s.
double getNu()
Returns the value of the parameter .
void setObservationTimes(double t[], int d)
Sets the observation times on the VarianceGammaProcess as usual, but also sets the observation times ...
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...