SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
InverseGaussianProcess.java
1/*
2 * Class: InverseGaussianProcess
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
58public class InverseGaussianProcess extends StochasticProcess {
59
60 protected RandomStream stream;
61
62 protected double delta;
63 protected double gamma;
64
65 protected double deltaOverGamma;
66 protected double deltaSquare;
67 // mu and lambda are the common names of the params for InverseGaussianGen.
68 protected double[] imu;
69 protected double[] ilam;
70
71 // Number of random streams needed by the current class
72 // to generate an IG process. For this class, = 1, for subclasses
73 // will sometimes be, = 2.
74 int numberOfRandomStreams;
75
76 // needed by InverseGaussianProcessMSH
77 protected InverseGaussianProcess() {
78 }
79
84 public InverseGaussianProcess(double s0, double delta, double gamma, RandomStream stream) {
85 this.x0 = s0;
86 setParams(delta, gamma);
87 this.stream = stream;
88 numberOfRandomStreams = 1;
89 }
90
91 public double[] generatePath() {
92 double s = x0;
93 for (int i = 0; i < d; i++) {
94 s += InverseGaussianGen.nextDouble(stream, imu[i], ilam[i]);
95 path[i + 1] = s;
96 }
97 observationIndex = d;
98 observationCounter = d;
99 return path;
100 }
101
109 public double[] generatePath(double[] uniforms01) {
110 double s = x0;
111 for (int i = 0; i < d; i++) {
112 s += InverseGaussianDist.inverseF(imu[i], ilam[i], uniforms01[i]);
113 path[i + 1] = s;
114 }
115 observationIndex = d;
116 observationCounter = d;
117 return path;
118 }
119
124 public double[] generatePath(double[] uniforms01, double[] uniforms01b) {
125 throw new UnsupportedOperationException("Use generatePath with 1 stream.");
126 }
127
128 public double nextObservation() {
129 double s = path[observationIndex];
130 s += InverseGaussianGen.nextDouble(stream, imu[observationIndex], ilam[observationIndex]);
131 observationIndex++;
132 observationCounter = observationIndex;
133 path[observationIndex] = s;
134 return s;
135 }
136
140 public void setParams(double delta, double gamma) {
141 this.delta = delta;
142 this.gamma = gamma;
143 deltaOverGamma = delta / gamma;
144 deltaSquare = delta * delta;
145 init();
146 }
147
151 public double getDelta() {
152 return delta;
153 }
154
158 public double getGamma() {
159 return gamma;
160 }
161
167 public double getAnalyticAverage(double time) {
168 return delta * time / gamma;
169 }
170
176 public double getAnalyticVariance(double time) {
177 return delta * delta * time * time;
178 }
179
180 protected void init() {
181 super.init(); // set path[0] to s0
182 if (observationTimesSet) {
183 x0 = t[0];
184 path[0] = x0;
185 imu = new double[d];
186 ilam = new double[d];
187 for (int j = 0; j < d; j++) {
188 double temp = delta * (t[j + 1] - t[j]);
189 imu[j] = temp / gamma;
190 ilam[j] = temp * temp;
191 }
192 }
193 }
194
196 // It is assumed that stream is always the same
197 // as the stream in the InverseGaussianGen.
198 return stream;
199 }
200
201 public void setStream(RandomStream stream) {
202 this.stream = stream;
203 }
204
212 return numberOfRandomStreams;
213 }
214
215}
Extends the class ContinuousDistribution for the inverse Gaussian distribution with location paramete...
double inverseF(double u)
Returns the inverse distribution function .
This class implements random variate generators for the inverse Gaussian distribution with location p...
static double nextDouble(RandomStream s, double mu, double lambda)
Generates a variate from the inverse gaussian distribution with location parameter and scale paramet...
double getAnalyticVariance(double time)
Returns the analytic variance which is , with.
double getAnalyticAverage(double time)
Returns the analytic average which is , with.
InverseGaussianProcess(double s0, double delta, double gamma, RandomStream stream)
Constructs a new InverseGaussianProcess.
void setStream(RandomStream stream)
Resets the random stream of the underlying generator to stream.
int getNumberOfRandomStreams()
Returns the number of random streams of this process.
double[] generatePath(double[] uniforms01, double[] uniforms01b)
This method does not work for this class, but will be useful for the subclasses that require two stre...
double[] generatePath()
Generates, returns, and saves the sample path .
double[] generatePath(double[] uniforms01)
Instead of using the internal stream to generate the path, uses an array of uniforms .
double nextObservation()
Generates and returns the next observation of the stochastic process.
void setParams(double delta, double gamma)
Sets the parameters.
RandomStream getStream()
Returns the random stream of the underlying generator.
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...