SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
GammaProcessPCA.java
1/*
2 * Class: GammaProcessPCA
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 * @authors Jean-Sébastien Parent and Maxime Dion
9 * @since july 2008
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.*;
30import umontreal.ssj.stat.*;
31import umontreal.ssj.stat.list.*;
32
48public class GammaProcessPCA extends GammaProcess {
49 double[] arrayTime;
51
62 public GammaProcessPCA(double s0, double mu, double nu, RandomStream stream) {
63 super(s0, mu, nu, new GammaGen(stream, new GammaDist(1.0)));
64 this.BMPCA = new BrownianMotionPCA(0.0, 0.0, Math.sqrt(nu), stream);
65 }
66
79 public GammaProcessPCA(double s0, double mu, double nu, GammaGen Ggen) {
80 super(s0, mu, nu, Ggen);
81 this.BMPCA = new BrownianMotionPCA(0.0, 0.0, Math.sqrt(nu), Ggen.getStream());
82 }
83
84 public double[] generatePath() {
85 double[] uniformsV = new double[d];
86 arrayTime = BMPCA.getObservationTimes();
87 int i;
88 double[] BMpath = BMPCA.generatePath();
89 double sigma;
90 for (i = 0; i < d; i++) {
91 sigma = BMPCA.getSigma() * Math.sqrt(arrayTime[i + 1] - arrayTime[i]);
92 uniformsV[i] = NormalDist.cdf01((BMpath[i + 1] - BMpath[i]) / sigma);
93 }
94 path[0] = x0;
95 for (i = 0; i < d; i++) {
96 path[i + 1] = path[i] + GammaDist.inverseF(mu2dtOverNu[i], muOverNu, 10, uniformsV[i]);
97 }
98 observationIndex = d;
99 observationCounter = d;
100 return path;
101 }
102
103 public double[] generatePath(double[] uniform01) {
104 double[] uniformsV = new double[d];
105 arrayTime = BMPCA.getObservationTimes();
106 int i;
107 double[] BMpath = BMPCA.generatePath(uniform01);
108 double sigma;
109 for (i = 0; i < d; i++) {
110 sigma = BMPCA.getSigma() * Math.sqrt(arrayTime[i + 1] - arrayTime[i]);
111 uniformsV[i] = NormalDist.cdf01((BMpath[i + 1] - BMpath[i]) / sigma);
112 }
113 path[0] = x0;
114 for (i = 0; i < d; i++) {
115 path[i + 1] = path[i] + GammaDist.inverseF(mu2dtOverNu[i], muOverNu, 10, uniformsV[i]);
116 }
117 observationIndex = d;
118 observationCounter = d;
119 return path;
120 }
121
126 public double nextObservation() {
127 throw new UnsupportedOperationException("nextObservation is not implemented in GammaProcessPCA");
128 }
129
134 public double nextObservation(double nextT) {
135 throw new UnsupportedOperationException("nextObservation is not implemented in GammaProcessPCA");
136 }
137
144 return BMPCA;
145 }
146
152 public void setObservationTimes(double[] t, int d) {
153 super.setObservationTimes(t, d);
154 BMPCA.setObservationTimes(t, d);
155 }
156
161 public void setParams(double s0, double mu, double nu) {
162 super.setParams(s0, mu, nu);
163 BMPCA.setParams(0.0, 0.0, Math.sqrt(nu));
164 }
165
172 public void setStream(RandomStream stream) {
173 super.setStream(stream);
174 this.BMPCA.setStream(stream);
175 }
176
177}
Extends the class ContinuousDistribution for the gamma distribution tjoh95a  (page 337) with shape pa...
double inverseF(double u)
Returns the inverse distribution function .
Extends the class ContinuousDistribution for the normal distribution (e.g., tjoh95a  (page 80)).
static double cdf01(double x)
Same as cdf(0, 1, x).
This class implements random variate generators for the gamma distribution.
Definition GammaGen.java:47
A Brownian motion process sampled using the principal component decomposition (PCA) fgla04a,...
void setStream(RandomStream stream)
Resets the random stream of the normal generator to stream.
void setParams(double s0, double mu, double nu)
Sets the parameters s0, and to new values, and sets the variance parameters of the BrownianMotionPC...
void setObservationTimes(double[] t, int d)
Sets the observation times of the GammaProcessPCA and the.
double[] generatePath()
Generates, returns and saves the path .
GammaProcessPCA(double s0, double mu, double nu, GammaGen Ggen)
Constructs a new GammaProcessPCA with parameters , and initial value .
double[] generatePath(double[] uniform01)
Generates, returns and saves the path .
BrownianMotionPCA getBMPCA()
Returns the BrownianMotionPCA that is included in the.
double nextObservation()
This method is not implemented in this class since the path cannot be generated sequentially.
GammaProcessPCA(double s0, double mu, double nu, RandomStream stream)
Constructs a new GammaProcessPCA with parameters , and initial value .
void setStream(RandomStream stream)
Resets the umontreal.ssj.rng.RandomStream of the gamma generator and the umontreal....
double nextObservation(double nextT)
This method is not implemented in this class since the path cannot be generated sequentially.
GammaProcess(double s0, double mu, double nu, RandomStream stream)
Constructs a new GammaProcess with parameters , and initial value .
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...