25package umontreal.ssj.stochprocess;
27import umontreal.ssj.rng.*;
28import umontreal.ssj.probdist.*;
29import umontreal.ssj.randvar.*;
30import umontreal.ssj.hups.*;
69 protected double[] stochTime;
75 protected double delta;
76 protected double alpha;
77 protected double beta;
78 protected double gamma;
91 this.streamBrownian = streamBrownian;
92 normalGen =
new NormalGen(streamBrownian);
95 this.streamIG2 = streamIG1;
113 this.streamIG1 = streamIG1;
114 this.streamIG2 = streamIG2;
115 this.streamBrownian = streamBrownian;
116 normalGen =
new NormalGen(streamBrownian);
120 if (igType.compareTo(
"SEQUENTIAL_SLOW") == 0)
124 else if (igType.compareTo(
"SEQUENTIAL_MSH") == 0)
126 else if (igType.compareTo(
"BRIDGE") == 0)
128 else if (igType.compareTo(
"PCA") == 0)
131 throw new IllegalArgumentException(
"Unrecognized igType");
140 this(x0, alpha, beta, mu, delta, streamAll, streamAll, streamAll, igType);
149 if (igProcess.getNumberOfRandomStreams() != 1)
150 return generatePathTwoIGStreams();
153 double[] randomNormal =
new double[d];
154 double[] randomIG1 =
new double[d];
155 for (
int j = 0; j < d; j++) {
156 randomIG1[j] = streamIG1.nextDouble();
157 randomNormal[j] = streamBrownian.nextDouble();
160 stochTime = igProcess.generatePath(randomIG1);
161 for (
int j = 0; j < d; j++) {
162 double dy = stochTime[j + 1] - stochTime[j];
166 observationIndex = d;
170 protected double[] generatePathTwoIGStreams() {
172 double[] uniformNormal =
new double[d];
173 double[] uniformIG1 =
new double[d];
174 double[] uniformIG2 =
new double[d];
176 for (
int j = 0; j < d; j++) {
178 uniformNormal[j] = streamBrownian.
nextDouble();
182 stochTime = igProcess.
generatePath(uniformIG1, uniformIG2);
183 for (
int j = 0; j < d; j++) {
184 double dy = stochTime[j + 1] - stochTime[j];
188 observationIndex = d;
201 double igNext = igProcess.nextObservation();
202 observationIndex = igProcess.getCurrentObservationIndex();
203 stochTime[observationIndex] = igNext;
204 double dY = igNext - stochTime[0];
205 double dT = t[observationIndex] - t[0];
206 path[observationIndex] = x0 + mu * dT + beta * dY + Math.sqrt(dY) * normalGen.nextDouble();
207 return path[observationIndex];
210 protected void init() {
213 if (observationTimesSet) {
214 stochTime =
new double[d + 1];
217 mudt =
new double[d];
218 for (
int i = 0; i < d; i++) {
219 dt[i] = t[i + 1] - t[i];
220 mudt[i] = dt[i] * mu;
232 super.setObservationTimes(t, d);
233 igProcess.setObservationTimes(t, d);
240 public void setParams(
double x0,
double alpha,
double beta,
double mu,
double delta) {
243 throw new IllegalArgumentException(
"delta <= 0");
245 throw new IllegalArgumentException(
"alpha <= 0");
246 if (Math.abs(beta) >= alpha)
247 throw new IllegalArgumentException(
"|beta| >= alpha");
255 gamma = Math.sqrt(alpha * alpha - beta * beta);
256 if (observationTimesSet)
299 return mu * time + delta * time * beta / gamma;
306 return delta * time * alpha * alpha / gamma / gamma / gamma;
314 if ((streamIG1 != streamIG2) || (streamIG1 != streamBrownian) || (streamIG1 != normalGen.getStream())
315 || (streamIG1 != igProcess.getStream()))
316 throw new UnsupportedOperationException(
"Two different streams or more are present");
325 streamIG1 = streamIG2 = streamBrownian = stream;
326 normalGen.setStream(stream);
327 igProcess.setStream(stream);
A variant of the class NormalDist (for the normal distribution with mean and variance ).
static double inverseF01(double u)
Same as inverseF(0.0, 1.0, u).
This class implements methods for generating random variates from the normal distribution .
Samples the path by bridge sampling: first finding the process value at the final time and then the m...
Uses a faster generating method (MSH) rmic76a than the simple inversion of the distribution function...
Approximates a principal component analysis (PCA) decomposition of the InverseGaussianProcess.
The inverse Gaussian process is a non-decreasing process where the increments are additive and are gi...
double[] generatePath()
Generates, returns, and saves the sample path .
void setParams(double delta, double gamma)
Sets the parameters.
RandomStream getStream()
Returns the random stream of the underlying generator.
double getAnalyticAverage(double time)
Returns the analytic average, which is .
NormalInverseGaussianProcess(double x0, double alpha, double beta, double mu, double delta, RandomStream streamBrownian, InverseGaussianProcess igP)
Given an InverseGaussianProcess igP, constructs a new NormalInverseGaussianProcess.
double getAlpha()
Returns alpha.
double nextObservation()
Returns the value of the process for the next time step.
NormalInverseGaussianProcess(double x0, double alpha, double beta, double mu, double delta, RandomStream streamBrownian, RandomStream streamIG1, RandomStream streamIG2, String igType)
Constructs a new NormalInverseGaussianProcess.
double getBeta()
Returns beta.
double getMu()
Returns mu.
void setParams(double x0, double alpha, double beta, double mu, double delta)
Sets the parameters.
double[] generatePath()
Generates the path.
double getAnalyticVariance(double time)
Returns the analytic variance, which is .
RandomStream getStream()
Only returns the stream if all streams are equal, including the stream(s) in the underlying InverseGa...
void setObservationTimes(double t[], int d)
Sets the observation times on the NIG process as usual, but also sets the observation times of the un...
double getDelta()
Returns delta.
void setStream(RandomStream stream)
Sets all internal streams to stream, including the stream(s) of the underlying InverseGaussianProcess...
double getGamma()
Returns gamma.
NormalInverseGaussianProcess(double x0, double alpha, double beta, double mu, double delta, RandomStream streamAll, String igType)
Same as above, but all umontreal.ssj.rng.RandomStream ’s are set to the same 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...
double nextDouble()
Returns a (pseudo)random number from the uniform distribution over the interval , using this stream,...