25package umontreal.ssj.stochprocess;
27import umontreal.ssj.rng.*;
28import umontreal.ssj.probdist.*;
29import umontreal.ssj.randvar.*;
40 protected double[][] A;
42 protected boolean isDecompPCA;
43 protected double[] sortedEigenvalues;
49 super(x0, mu, sigma, stream);
57 super(x0, mu, sigma, gen);
62 throw new UnsupportedOperationException(
"nextObservation() not defined for PCA.");
69 for (
int j = 0; j < d; j++)
70 z[j] = gen.nextDouble();
71 for (
int j = 0; j < d; j++) {
73 for (
int k = 0; k < d; k++)
74 sum += A[j][k] * z[k];
75 path[j + 1] = x0 + mu * t[j + 1] + sum;
78 observationCounter = d;
86 for (
int j = 0; j < d; j++)
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;
100 super.setObservationTimes(t, d);
101 this.dt = t[1] - t[0];
102 for (
int i = 1; i < d; i++)
103 if (Math.abs((t[i + 1] - t[i]) / dt - 1.0) > 1e-7)
104 throw new IllegalArgumentException(
"Not equidistant times");
109 super.setObservationTimes(dt, d);
112 protected void init() {
114 if (observationTimesSet) {
115 final double twoOverSqrt2dP1 = 2.0 / Math.sqrt(2.0 * d + 1.0);
116 final double piOver2dP1 = Math.PI / (2.0 * d + 1.0);
120 A =
new double[d][d];
121 sortedEigenvalues =
new double[d];
122 for (
int ic = 1; ic <= d; ic++) {
123 final double tempSin = Math.sin((2 * ic - 1) * piOver2dP1 / 2.0);
124 sortedEigenvalues[ic - 1] = dt / 4.0 / tempSin / tempSin * sigma * sigma;
125 for (
int ir = 1; ir <= d; ir++) {
126 A[ir - 1][ic - 1] = twoOverSqrt2dP1 * Math.sin((2 * ic - 1) * piOver2dP1 * ir);
127 A[ir - 1][ic - 1] *= Math.sqrt(sortedEigenvalues[ic - 1]);
130 double[][] AA =
new double[d][d];
131 for (
int ic = 0; ic < d; ic++) {
132 for (
int ir = 0; ir < d; ir++) {
134 for (
int k = 0; k < d; k++)
135 sum += A[ir][k] * A[ic][k];
143 public double[] getSortedEigenvalues() {
144 return sortedEigenvalues;
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 .
double nextObservation()
Generates and returns the next observation of the stochastic process.
double[] generatePath()
Generates, returns, and saves the sample path .
void setObservationTimes(double[] t, int d)
Sets the observation times of the process to a copy of T, with.
BrownianMotionPCAEqualSteps(double x0, double mu, double sigma, NormalGen gen)
Constructs a new BrownianMotionPCAEqualSteps.
void setObservationTimes(double dt, int d)
Sets equidistant observation times at , for.
double[] generatePath(double[] QMCpointsBM)
Same as generatePath(), but a vector of uniform random numbers must be provided to the method.
BrownianMotionPCAEqualSteps(double x0, double mu, double sigma, RandomStream stream)
Constructs a new BrownianMotionPCAEqualSteps.
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...