SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
GeometricLevyProcess.java
1/*
2 * Class: GeometricLevyProcess
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
9 * @since
10 *
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 */
25package umontreal.ssj.stochprocess;
26
27import umontreal.ssj.rng.*;
28
45public abstract class GeometricLevyProcess extends StochasticProcess {
46
47 protected StochasticProcess levyProcess;
48 protected double omegaRiskNeutralCorrection;
49 protected double muGeom; // usually the interest rate
50 protected double[] muGeomRNdt; // risk neutral corrected
51 protected double[] muGeomRNdT; // risk neutral corrected, from time t0.
52
53 protected void init() {
54 super.init();
55 if (observationTimesSet) {
56 // Telling the g\'eom\'etric process about the observation times
57 levyProcess.setObservationTimes(t, d);
58
59 // We need to know in which order the observations are generated
60 this.observationIndexFromCounter = levyProcess.getArrayMappingCounterToIndex();
61
62 muGeomRNdt = new double[d];
63 for (int i = 0; i < d; i++) {
64 muGeomRNdt[i] = (muGeom - omegaRiskNeutralCorrection) * (t[i + 1] - t[i]);
65 }
66 muGeomRNdT = new double[d + 1];
67 for (int i = 0; i <= d; i++) {
68 muGeomRNdT[i] = (muGeom - omegaRiskNeutralCorrection) * (t[i] - t[0]);
69 }
70 }
71 }
72
76 public double[] generatePath() {
77 double s = x0;
79 double[] arithmPath = levyProcess.generatePath();
80 for (int i = 0; i < d; i++) {
81 s *= Math.exp(muGeomRNdt[i] + arithmPath[i + 1] - arithmPath[i]);
82 path[i + 1] = s;
83 }
84 observationIndex = d;
85 return path;
86 }
87
94 public double nextObservation() {
95 double levy = levyProcess.nextObservation();
96 observationIndex = levyProcess.getCurrentObservationIndex();
97 path[observationIndex] = x0 * Math.exp(muGeomRNdT[observationIndex] + levy);
98 return path[observationIndex];
99 }
100
105 public void resetStartProcess() {
106 super.init();
107 levyProcess.resetStartProcess();
108 }
109
114 public void setObservationTimes(double[] time, int d) {
115 super.setObservationTimes(time, d);
116 levyProcess.setObservationTimes(time, d);
117 }
118
122 public double getOmega() {
123 return omegaRiskNeutralCorrection;
124 }
125
130 public double getMuGeom() {
131 return muGeom;
132 }
133
137 public void setMuGeom(double muGeom) {
138 this.muGeom = muGeom;
139 }
140
145 return levyProcess;
146 }
147
155 public void resetRiskNeutralCorrection(double omegaRN) {
156 omegaRiskNeutralCorrection = omegaRN;
157 init();
158 }
159
166 return levyProcess.getStream();
167 }
168
174 public void setStream(RandomStream stream) {
175 levyProcess.setStream(stream);
176 }
177
178}
Abstract class used as a parent class for the exponentiation of a Lévy process :
void resetRiskNeutralCorrection(double omegaRN)
Changes the value of .
double nextObservation()
Returns the next observation.
double getMuGeom()
Returns the geometric drift parameter, which is usually the interest rate, .
void setMuGeom(double muGeom)
Sets the drift parameter (interest rate) of the geometric term.
void resetStartProcess()
Resets the step counter of the geometric process and the underlying Lévy process to the start value.
RandomStream getStream()
Returns the stream from the underlying Lévy process.
void setStream(RandomStream stream)
Resets the stream in the underlying Lévy process.
double getOmega()
Returns the risk neutral correction.
StochasticProcess getLevyProcess()
Returns the Lévy process.
void setObservationTimes(double[] time, int d)
Sets the observation times on the geometric process and the underlying Lévy process.
Abstract base class for a stochastic process sampled (or observed) at a finite number of time points...
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...