25package umontreal.ssj.stochprocess;
27import umontreal.ssj.rng.*;
28import umontreal.ssj.probdist.*;
29import umontreal.ssj.randvar.*;
30import cern.colt.matrix.DoubleMatrix2D;
31import cern.colt.matrix.impl.DenseDoubleMatrix2D;
32import cern.colt.matrix.linalg.*;
44 protected double[][] sigmaCov;
46 protected double[][] A;
48 protected double[] sortedEigenvalues;
49 protected boolean isDecompPCA;
58 super(x0, mu, sigma, stream);
68 super(x0, mu, sigma, gen);
73 throw new UnsupportedOperationException(
"nextObservation() is not defined in BrownianMotionPCA");
76 public void setParams(
double x0,
double mu,
double sigma) {
77 super.setParams(x0, mu, sigma);
86 for (
int j = 0; j < d; j++)
87 z[j] = gen.nextDouble();
88 for (
int j = 0; j < d; j++) {
90 for (
int k = 0; k < d; k++)
91 sum += A[j][k] * z[k];
92 path[j + 1] = x0 + mu * t[j + 1] + sum;
95 observationCounter = d;
103 for (
int j = 0; j < d; j++)
105 for (
int j = 0; j < d; j++) {
107 for (
int k = 0; k < d; k++)
108 sum += A[j][k] * z[k];
109 path[j + 1] = x0 + mu * t[j + 1] + sum;
111 observationIndex = d;
112 observationCounter = d;
116 public double[][] decompPCA(
double[][] sigma) {
120 SingularValueDecomposition sv =
new SingularValueDecomposition(
new DenseDoubleMatrix2D(sigma));
121 DoubleMatrix2D D = sv.getS();
123 for (
int i = 0; i < D.rows(); i++) {
124 sortedEigenvalues[i] = D.getQuick(i, i);
125 D.setQuick(i, i, Math.sqrt(D.getQuick(i, i)));
127 DoubleMatrix2D P = sv.getV();
128 return P.zMult(D,
null).toArray();
135 return sortedEigenvalues;
138 protected void init() {
141 sortedEigenvalues =
new double[d];
144 sigmaCov =
new double[d][d];
145 for (
int i = 0; i < d; i++) {
146 for (
int j = i; j < d; j++) {
147 sigmaCov[i][j] = sigma * sigma * t[i + 1];
148 sigmaCov[j][i] = sigmaCov[i][j];
151 A = decompPCA(sigmaCov);
Extends the class ContinuousDistribution for the normal distribution (e.g., tjoh95a (page 80)).
static double inverseF01(double u)
Same as inverseF(0, 1, u).
This class implements methods for generating random variates from the normal distribution .
void setParams(double x0, double mu, double sigma)
Resets the parameters , and of the process.
double[] generatePath(double[] uniform01)
Same as generatePath(), but a vector of uniform random numbers must be provided to the method.
BrownianMotionPCA(double x0, double mu, double sigma, RandomStream stream)
Constructs a new BrownianMotionBridge with parameters , and initial value .
double nextObservation()
Generates and returns the next observation of the stochastic process.
double[] generatePath()
Generates, returns, and saves the sample path .
BrownianMotionPCA(double x0, double mu, double sigma, NormalGen gen)
Constructs a new BrownianMotionBridge with parameters , and initial value .
double[] getSortedEigenvalues()
Returns the sorted eigenvalues obtained in the PCA decomposition.
BrownianMotion(double x0, double mu, double sigma, RandomStream stream)
Constructs a new BrownianMotion with parameters mu,.
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...