SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
MultivariateStochasticProcess.java
1/*
2 * Class: MultivariateStochasticProcess
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 * 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
46public abstract class MultivariateStochasticProcess extends StochasticProcess {
47
48 protected double[] x0; // Default value of the process at time t_0.
49 protected int c = 1; // Dimension of the process.
50
61 public abstract double[] generatePath();
62
70 public void getSubpath(double[] subpath, int[] pathIndices) {
71 for (int j = 0; j < pathIndices.length; j++) {
72 for (int i = 0; i < c; i++) {
73 subpath[c * j + i] = path[c * pathIndices[j] + i];
74 }
75 }
76 }
77
84 public void setObservationTimes(double[] t, int d) {
85 if (d <= 0)
86 throw new IllegalArgumentException("Number of observation times d <= 0");
87
88 this.d = d;
89 observationTimesSet = true;
90
91 /*** Copy of the observation times ***/
92 this.t = new double[d + 1];
93 System.arraycopy(t, 0, this.t, 0, d + 1);
94
95 /*** Test chronological order ***/
96 for (int i = 0; i < d; i++) {
97 if (t[i + 1] < t[i])
98 throw new IllegalArgumentException("Observation times t[] are not ordered chronologically");
99 }
100
101 /***
102 * Process specific initialization; usually precomputes quantities that depend
103 * on the observation times.
104 ***/
105 init();
106 }
107
111 public void getObservation(int j, double[] obs) {
112 for (int i = 0; i < c; i++)
113 obs[i] = path[c * j + i];
114 }
115
119 public double getObservation(int j, int i) {
120 return path[c * j + i];
121 }
122
128 public abstract void nextObservationVector(double[] obs);
129
135 public void getCurrentObservation(double[] obs) {
136 for (int i = 0; i < c; i++)
137 obs[i] = path[c * observationIndex + i];
138 }
139
143 public double[] getX0(double[] x0) {
144 for (int i = 0; i < c; i++)
145 x0[i] = this.x0[i];
146 return x0;
147 }
148
149 protected void init() {
150 if (observationTimesSet)
151 createPath();
152 if (path != null) // If observation times are not defined, do nothing.
153 for (int i = 0; i < c; i++)
154 path[i] = x0[i];
155 }
156
157 /*** Called by 'init' to create new path ***/
158 protected void createPath() {
159 path = new double[c * (d + 1)];
160 }
161
165 public int getDimension() {
166 return c;
167 }
168
169}
This class is a multivariate version of StochasticProcess where the process evolves in the -dimension...
void getObservation(int j, double[] obs)
Returns in the -dimensional vector obs.
void getSubpath(double[] subpath, int[] pathIndices)
Returns in subpath the values of the process at a subset of the observation times,...
abstract 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.
void getCurrentObservation(double[] obs)
Returns the value of the last generated observation.
abstract void nextObservationVector(double[] obs)
Generates and returns in obs the next observation.
double getObservation(int j, int i)
Returns from the current sample path.
double[] getX0(double[] x0)
Returns in x0 the initial value for this process.
Abstract base class for a stochastic process sampled (or observed) at a finite number of time points...