24package umontreal.ssj.stochprocess;
26import umontreal.ssj.rng.*;
27import umontreal.ssj.probdist.*;
28import umontreal.ssj.randvar.*;
29import cern.colt.matrix.DoubleMatrix2D;
30import cern.colt.matrix.impl.*;
31import cern.colt.matrix.linalg.*;
32import cern.colt.matrix.doublealgo.*;
50 protected DoubleMatrix2D BigSigma;
52 protected DoubleMatrix2D decompPCABigSigma;
53 protected DoubleMatrix2D C;
54 protected DoubleMatrix2D A;
55 protected double[] z, zz;
56 protected boolean decompPCA;
91 public void setParams(
int c,
double[] x0,
double[] mu,
double[] sigma,
double[][] corrZ) {
93 super.setParams(c, x0, mu, sigma, corrZ);
96 protected DoubleMatrix2D decompPCA(DoubleMatrix2D BigSigma) {
100 SingularValueDecomposition sv =
new SingularValueDecomposition(BigSigma);
101 DoubleMatrix2D D = sv.getS();
103 for (
int i = 0; i < D.rows(); ++i)
104 D.setQuick(i, i, Math.sqrt(D.getQuick(i, i)));
105 DoubleMatrix2D P = sv.getV();
106 return P.zMult(D,
null);
110 protected void init() {
113 BigSigma =
new DenseDoubleMatrix2D(c * d, c * d);
114 for (
int i = 0; i < d; ++i) {
115 for (
int j = 0; j < d; ++j) {
116 for (
int k = 0; k < c; ++k) {
117 for (
int l = 0; l < c; ++l) {
118 g = (i <= j ? i + 1 : j + 1);
120 BigSigma.setQuick(i * c + k, j * c + l, g * sigma[k] * sigma[l] * (t[i + 1] - t[i]));
122 BigSigma.setQuick(i * c + k, j * c + l, g * covZ.getQuick(k, l) * (t[i + 1] - t[i]));
127 decompPCABigSigma = decompPCA(BigSigma);
134 double[] z =
new double[c * d];
139 for (i = 0; i < c * d; i++)
140 z[i] = gen.nextDouble();
142 for (j = 0; j < d; j++)
143 for (i = 0; i < c; i++) {
145 for (k = 0; k < c * d; k++) {
146 sum += decompPCABigSigma.getQuick(c * j + i, k) * z[k];
148 path[c * (j + 1) + i] = sum + mu[i] * (t[j + 1] - t[0]) + x0[i];
151 observationIndex = d;
162 for (j = 0; j < d; j++)
163 for (i = 0; i < c; i++) {
165 for (k = 0; k < c * d; k++) {
166 sum += decompPCABigSigma.getQuick(c * j + i, k) * uniform01[k];
168 path[c * (j + 1) + i] = sum + mu[i] * (t[j + 1] - t[0]) + x0[i];
171 observationIndex = d;
Extends the class ContinuousDistribution for the normal distribution (e.g., tjoh95a (page 80)).
This class implements methods for generating random variates from the normal distribution .
double[] generatePath()
Generates, returns, and saves the sample path.
MultivariateBrownianMotionPCABigSigma(int c, double[] x0, double[] mu, double[] sigma, double[][] corrZ, RandomStream stream)
Constructs a new MultivariateBrownianMotionPCABigSigma with parameters ,.
MultivariateBrownianMotionPCABigSigma(int c, double[] x0, double[] mu, double[] sigma, double[][] corrZ, NormalGen gen)
Constructs a new MultivariateBrownianMotionPCABigSigma with parameters ,.
void setParams(int c, double[] x0, double[] mu, double[] sigma, double[][] corrZ)
Sets the dimension , the initial value.
double[] generatePath(double[] uniform01)
Same as generatePath() but requires a vector of uniform random numbers which are used to generate the...
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...