SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
MultivariateGeometricBrownianMotion.java
1/*
2 * Class: MultivariateGeometricBrownianMotion
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 * @author Jean-Sébastien Parent & Clément Teule
9 * @since 2008
10
11 * SSJ is free software: you can redistribute it and/or modify it under
12 * the terms of the GNU General Public License (GPL) as published by the
13 * Free Software Foundation, either version 3 of the License, or
14 * any later version.
15
16 * SSJ is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20
21 * A copy of the GNU General Public License is available at
22 <a href="http://www.gnu.org/licenses">GPL licence site</a>.
23 */
24package umontreal.ssj.stochprocess;
25
26import umontreal.ssj.rng.*;
27import umontreal.ssj.probdist.*;
28import umontreal.ssj.randvar.*;
29
46
47 protected NormalGen gen;
48 protected MultivariateBrownianMotion mbm; // The underlying BM process X.
49 protected double[] mu, sigma;
50 protected double[] mudt;
51
65 public MultivariateGeometricBrownianMotion(int c, double[] x0, double[] mu, double[] sigma,
67 this.mbm = mbm;
68 setParams(c, x0, mu, sigma);
69 }
70
77 public void setObservationTimes(double[] t, int d) {
78 this.d = d;
79 super.setObservationTimes(t, d);
80 mbm.setObservationTimes(t, d);
81 }
82
83 public double[] nextObservationVector() {
84 // Note : this implementation is general, to deal with
85 // the possibility of generating bm with bridge sampling, for example. ???
86
87 // Note Clément :
88 // Problème car x0 est un double[], pas un double
89// double s = x0 * Math.exp (mbm.nextObservationVector());
90// path[observationCounter] = s;
91//
92// observationCounter = mbm.getCurrentObservationIndex();
93// // Could be different than simply 'observationCounter++' because of the
94// // possibility of Brownian bridge
95//
96// return s;
97 throw new UnsupportedOperationException("nextObservationVector is not implemented ");
98 }
99
103 public void nextObservationVector(double[] obs) {
104 throw new UnsupportedOperationException("nextObservationVector is not implemented ");
105 }
106
107 public double[] generatePath() {
108 for (int i = 0; i < c; i++)
109 path[i] = x0[i];
110 mbm.generatePath();
111 for (int j = 1; j <= d; j++)
112 for (int i = 0; i < c; i++)
113 path[c * j + i] = x0[i] * Math.exp(mbm.getObservation(j, i));
114 observationCounter = d;
115 return path;
116 }
117
122 public void resetStartProcess() {
123 observationCounter = 0;
124 mbm.resetStartProcess();
125 }
126
133 public void setParams(int c, double[] x0, double[] mu, double[] sigma) {
134 if (x0.length < c)
135 throw new IllegalArgumentException(
136 "x0 dimension : " + x0.length + " is smaller than the process dimension : " + c);
137 if (mu.length < c)
138 throw new IllegalArgumentException(
139 "mu dimension : " + mu.length + " is smaller than the process dimension : " + c);
140 if (sigma.length < c)
141 throw new IllegalArgumentException(
142 "sigma dimension : " + sigma.length + " is smaller than the process dimension : " + c);
143
144 double[] zero = new double[c];
145 this.c = c;
146 this.x0 = x0;
147 this.mu = new double[c];
148 for (int i = 0; i < c; i++) {
149 this.mu[i] = mu[i] - 0.5 * sigma[i] * sigma[i];
150 zero[i] = 0.0;
151 }
152 mbm.setParams(zero, this.mu, sigma); // reconstructs the MBM with the proper parameters
153 if (observationTimesSet)
154 init(); // Otherwise not needed.
155 }
156
160 public void setStream(RandomStream stream) {
161 (mbm.gen).setStream(stream);
162 }
163
168 return (mbm.gen).getStream();
169 }
170
174 public NormalGen getGen() {
175 return gen;
176 }
177
183 return mbm;
184 }
185
186 protected void init() {
187 super.init();
188 }
189
190}
This class implements methods for generating random variates from the normal distribution .
This class represents a multivariate Brownian motion process.
void nextObservationVector(double[] obs)
Generates and returns the vector of next observations.
MultivariateBrownianMotion getBrownianMotion()
Returns a reference to the MultivariateBrownianMotion object used to generate the process.
void setParams(int c, double[] x0, double[] mu, double[] sigma)
Sets the parameters , and of the process.
void setStream(RandomStream stream)
Resets the random stream for the underlying Brownian motion to stream.
void setObservationTimes(double[] t, int d)
Sets the observation times of the MultivariateGeometricBrownianMotion, but also those of the inner.
RandomStream getStream()
Returns the random stream for the underlying Brownian motion.
void resetStartProcess()
Same as in StochasticProcess, but also invokes resetStartProcess for the underlying BrownianMotion ob...
MultivariateGeometricBrownianMotion(int c, double[] x0, double[] mu, double[] sigma, MultivariateBrownianMotion mbm)
Constructs a new MultivariateGeometricBrownianMotion with parameters , , and , using mbm as the under...
NormalGen getGen()
Returns the normal random variate generator used.
double[] generatePath()
Generates, returns, and saves the sample path.
This class is a multivariate version of StochasticProcess where the process evolves in the -dimension...
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...