48 protected double[] z, covZCholDecompz;
49 protected int bridgeCounter = -1;
52 protected double[] wMuDt, wSqrtDt;
53 protected int[] wIndexList, ptIndex;
70 covZCholDecompz =
new double[c];
87 covZCholDecompz =
new double[c];
92 if (!covZiSCholDecomp) {
95 int oldIndexL, oldIndexR, newIndex, i, j;
97 for (i = 0; i < c; i++)
98 z[i] = gen.nextDouble();
100 computeAZ(covZCholDecomp, z, covZCholDecompz);
101 for (i = 0; i < c; i++) {
102 path[c * d + i] = x0[i] + mu[i] * (t[d] - t[0]) + wSqrtDt[0] * covZCholDecompz[i];
105 for (j = 0; j < 3 * (d - 1); j += 3) {
107 for (i = 0; i < c; i++)
108 z[i] = gen.nextDouble();
110 computeAZ(covZCholDecomp, z, covZCholDecompz);
111 oldIndexL = wIndexList[j];
112 newIndex = wIndexList[j + 1];
113 oldIndexR = wIndexList[j + 2];
114 for (i = 0; i < c; i++) {
115 path[c * newIndex + i] = path[c * oldIndexL + i]
116 + (path[c * oldIndexR + i] - path[c * oldIndexL + i]) * wMuDt[newIndex]
117 + wSqrtDt[newIndex] * covZCholDecompz[i];
124 observationIndex = observationCounter = c * d;
129 observationIndex = 0;
130 observationCounter = 0;
135 throw new UnsupportedOperationException(
"nextObservationVector is not implemented ");
139 throw new UnsupportedOperationException(
"nextObservationVector is not implemented ");
142 protected void init() {
148 wMuDt =
new double[d + 1];
149 wSqrtDt =
new double[d + 1];
150 wIndexList =
new int[3 * (d)];
151 ptIndex =
new int[d + 1];
153 int indexCounter = 0;
154 int newIndex, oldLeft, oldRight;
155 int i, j, k, powOfTwo;
157 for (i = 0; i < c; i++)
165 wSqrtDt[0] = Math.sqrt(t[d] - t[0]);
168 for (powOfTwo = 1; powOfTwo <= d / 2; powOfTwo *= 2) {
170 for (j = powOfTwo; j >= 1; j--) {
171 ptIndex[2 * j] = ptIndex[j];
175 for (j = 1; j <= powOfTwo; j++) {
178 newIndex = (int) (0.5 * (ptIndex[oldLeft] + ptIndex[oldRight]));
180 wMuDt[newIndex] = (t[newIndex] - t[ptIndex[oldLeft]]) / (t[ptIndex[oldRight]] - t[ptIndex[oldLeft]]);
182 wSqrtDt[newIndex] = Math.sqrt((t[newIndex] - t[ptIndex[oldLeft]]) * (t[ptIndex[oldRight]] - t[newIndex])
183 / (t[ptIndex[oldRight]] - t[ptIndex[oldLeft]]));
185 ptIndex[oldLeft + 1] = newIndex;
186 wIndexList[indexCounter] = ptIndex[oldLeft];
187 wIndexList[indexCounter + 1] = newIndex;
188 wIndexList[indexCounter + 2] = ptIndex[oldRight];
194 for (k = 1; k < d; k++) {
195 if (ptIndex[k - 1] + 1 < ptIndex[k]) {
197 wMuDt[ptIndex[k - 1] + 1] = (t[ptIndex[k - 1] + 1] - t[ptIndex[k - 1]])
198 / (t[ptIndex[k]] - t[ptIndex[k - 1]]);
199 wSqrtDt[ptIndex[k - 1] + 1] = Math.sqrt((t[ptIndex[k - 1] + 1] - t[ptIndex[k - 1]])
200 * (t[ptIndex[k]] - t[ptIndex[k - 1] + 1]) / (t[ptIndex[k]] - t[ptIndex[k - 1]]));
201 wIndexList[indexCounter] = ptIndex[k] - 2;
202 wIndexList[indexCounter + 1] = ptIndex[k] - 1;
203 wIndexList[indexCounter + 2] = ptIndex[k];
210 private void computeAZ(DoubleMatrix2D A,
double z[],
double Az[]) {
211 for (
int i = 0; i < c; i++) {
213 for (
int k = 0; k < c; k++)
214 sum += A.getQuick(i, k) * z[k];
MultivariateBrownianMotionBridge(int c, double[] x0, double[] mu, double[] sigma, double[][] corrZ, RandomStream stream)
Constructs a new MultivariateBrownianMotionBridge with parameters mu,.
MultivariateBrownianMotionBridge(int c, double[] x0, double[] mu, double[] sigma, double[][] corrZ, NormalGen gen)
Constructs a new MultivariateBrownianMotionBridge with parameters mu,.