SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
GammaProcessPCASymmetricalBridge.java
1/*
2 * Class: GammaProcessPCASymmetricalBridge
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.*;
30
42
54 public GammaProcessPCASymmetricalBridge(double s0, double mu, double nu, RandomStream stream) {
55 super(s0, mu, nu, stream);
56 }
57
58 public double[] generatePath(double[] uniform01) {
59 // uniformsV[] of size d+1, but element 0 never used.
60 double[] uniformsV = new double[d + 1];
61
62 // generate BrownianMotion PCA path
63 double[] BMPCApath = BMPCA.generatePath(uniform01);
64 int oldIndexL;
65 int newIndex;
66 int oldIndexR;
67 double temp, y;
68 // Transform BMPCA points to uniforms using an inverse bridge.
69 for (int j = 0; j < 3 * (d - 1); j += 3) {
70 oldIndexL = BMBridge.wIndexList[j];
71 newIndex = BMBridge.wIndexList[j + 1];
72 oldIndexR = BMBridge.wIndexList[j + 2];
73
74 temp = BMPCApath[newIndex] - BMPCApath[oldIndexL];
75 temp -= (BMPCApath[oldIndexR] - BMPCApath[oldIndexL]) * BMBridge.wMuDt[newIndex];
76 temp /= BMBridge.wSqrtDt[newIndex];
77 uniformsV[newIndex] = NormalDist.cdf01(temp);
78 }
79 double dT = BMPCA.t[d] - BMPCA.t[0];
80 uniformsV[d] = NormalDist.cdf01((BMPCApath[d] - BMPCApath[0] - BMPCA.mu * dT) / (BMPCA.sigma * Math.sqrt(dT)));
81
82 // Reconstruct the bridge for the GammaProcess from the Brownian uniforms.
83 // Here we have to hope that the bridge is implemented in the
84 // same order for the Brownian and Gamma processes.
85
86 path[0] = x0;
87 path[d] = x0 + GammaDist.inverseF(mu2dTOverNu, muOverNu, 10, uniformsV[d]);
88 for (int j = 0; j < 3 * (d - 1); j += 3) {
89 oldIndexL = wIndexList[j];
90 newIndex = wIndexList[j + 1];
91 oldIndexR = wIndexList[j + 2];
92
93 y = BetaSymmetricalDist.inverseF(bMu2dtOverNuL[newIndex], uniformsV[newIndex]);
94
95 path[newIndex] = path[oldIndexL] + (path[oldIndexR] - path[oldIndexL]) * y;
96 }
97 // resetStartProcess();
98 observationIndex = d;
99 observationCounter = d;
100 return path;
101 }
102
103 public double[] generatePath() {
104 double[] u = new double[d];
105 for (int i = 0; i < d; i++)
106 u[i] = stream.nextDouble();
107 return generatePath(u);
108 }
109
110 // code taken from GammaSymmetricalBridge to check time is power of 2,
111 // as it is required for the symmetrical bridge.
112 protected void init() {
113 super.init();
114 if (observationTimesSet) {
115
116 /* Testing to make sure number of observations n = 2^k */
117 int x = d;
118 int y = 1;
119 while (x > 1) {
120 x = x / 2;
121 y = y * 2;
122 }
123 if (y != d)
124 throw new IllegalArgumentException(
125 "GammaSymmetricalBridgeProcess:" + "Number 'n' of observation times is not a power of 2");
126 }
127 }
128}
Specializes the class BetaDist to the case of a symmetrical beta distribution over the interval ,...
double inverseF(double u)
Returns the inverse distribution function .
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).
GammaProcessPCABridge(double s0, double mu, double nu, RandomStream stream)
Constructs a new GammaProcessPCABridge with parameters , and initial value .
GammaProcessPCASymmetricalBridge(double s0, double mu, double nu, RandomStream stream)
Constructs a new GammaProcessPCASymmetricalBridge with parameters.
double[] generatePath(double[] uniform01)
Generates, returns and saves the path .
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...