umontreal.iro.lecuyer.stochprocess
Class StochasticProcess
- java.lang.Object
-
- umontreal.iro.lecuyer.stochprocess.StochasticProcess
-
- Direct Known Subclasses:
- BrownianMotion, CIRProcess, CIRProcessEuler, GammaProcess, GeometricBrownianMotion, GeometricLevyProcess, GeometricVarianceGammaProcess, InverseGaussianProcess, NormalInverseGaussianProcess, OrnsteinUhlenbeckProcess, VarianceGammaProcess
public abstract class StochasticProcess extends java.lang.ObjectAbstract base class for a stochastic process {X(t) : t >= 0} sampled (or observed) at a finite number of time points, 0 = t0 < t1 < ... < td. The observation times are usually all specified before generating a sample path. This can be done via setObservationTimes. The method generatePath generates X(t1),..., X(td) and memorizes them in a vector, which can be recovered by getPath.Alternatively, for some types of processes, the observations X(tj) can be generated sequentially, one at a time, by invoking resetStartProcess first, and then nextObservation repeatedly. For some types of processes, the observation times can be specified one by one as well, when generating the path. This may be convenient or even necessary if the observation times are random, for example.
WARNING: After having called the constructor for one of the subclass, one must always set the observation times of the process, by calling method setObservationTimes for example or otherwise.
-
-
Constructor Summary
Constructors Constructor and Description StochasticProcess()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description abstract double[]generatePath()Generates, returns, and saves the sample path {X(t0), X(t1),…, X(td)}.double[]generatePath(RandomStream stream)Same as generatePath(), but first resets the stream to stream.int[]getArrayMappingCounterToIndex()Returns a reference to an array that maps an integer k to ik, the index of the observation S(tik) corresponding to the k-th observation to be generated for a sample path of this process.doublegetCurrentObservation()Returns the value of the last generated observation X(tj).intgetCurrentObservationIndex()Returns the value of the index j corresponding to the time tj of the last generated observation.intgetNbObservationTimes()Returns the number of observation times excluding the time t0.doublegetObservation(int j)Returns X(tj) from the current sample path.double[]getObservationTimes()Returns a reference to the array that contains the observation times (t0,..., td).double[]getPath()Returns a reference to the last generated sample path {X(t0),..., X(td)}.abstract RandomStreamgetStream()Returns the random stream of the underlying generator.voidgetSubpath(double[] subpath, int[] pathIndices)Returns in subpath the values of the process at a subset of the observation times, specified as the times tj whose indices j are in the array pathIndices.doublegetX0()Returns the initial value X(t0) for this process.booleanhasNextObservation()Returns true if j < d, where j is the number of observations of the current sample path generated since the last call toresetStartProcess.doublenextObservation()Generates and returns the next observation X(tj) of the stochastic process.voidresetStartProcess()Resets the observation counter to its initial value j = 0, so that the current observation X(tj) becomes X(t0).voidsetObservationTimes(double[] T, int d)Sets the observation times of the process to a copy of T, with t0 = T[0] and td = T[d].voidsetObservationTimes(double delta, int d)Sets equidistant observation times at tj = jδ, for j = 0,..., d, and delta = δ.abstract voidsetStream(RandomStream stream)Resets the random stream of the underlying generator to stream.voidsetX0(double s0)Sets the initial value X(t0) for this process to s0, and reinitializes.
-
-
-
Method Detail
-
setObservationTimes
public void setObservationTimes(double[] T, int d)Sets the observation times of the process to a copy of T, with t0 = T[0] and td = T[d]. The size of T must be d + 1.
-
setObservationTimes
public void setObservationTimes(double delta, int d)Sets equidistant observation times at tj = jδ, for j = 0,..., d, and delta = δ.
-
getObservationTimes
public double[] getObservationTimes()
Returns a reference to the array that contains the observation times (t0,..., td). Warning: This method should only be used to read the observation times. Changing the values in the array directly may have unexpected consequences. The method setObservationTimes should be used to modify the observation times.
-
getNbObservationTimes
public int getNbObservationTimes()
Returns the number of observation times excluding the time t0.
-
generatePath
public abstract double[] generatePath()
Generates, returns, and saves the sample path {X(t0), X(t1),…, X(td)}. It can then be accessed via getPath, getSubpath, or getObservation. The generation method depends on the process type.
-
generatePath
public double[] generatePath(RandomStream stream)
Same as generatePath(), but first resets the stream to stream.
-
getPath
public double[] getPath()
Returns a reference to the last generated sample path {X(t0),..., X(td)}. Warning: The returned array and its size should not be modified, because this is the one that memorizes the observations (not a copy of it). To obtain a copy, use getSubpath instead.
-
getSubpath
public void getSubpath(double[] subpath, int[] pathIndices)Returns in subpath the values of the process at a subset of the observation times, specified as the times tj whose indices j are in the array pathIndices. The size of pathIndices should be at least as much as that of subpath.
-
getObservation
public double getObservation(int j)
Returns X(tj) from the current sample path. Warning: If the observation X(tj) for the current path has not yet been generated, then the value returned is unpredictable.
-
resetStartProcess
public void resetStartProcess()
Resets the observation counter to its initial value j = 0, so that the current observation X(tj) becomes X(t0). This method should be invoked before generating observations sequentially one by one vianextObservation, for a new sample path.
-
hasNextObservation
public boolean hasNextObservation()
Returns true if j < d, where j is the number of observations of the current sample path generated since the last call toresetStartProcess. Otherwise returns false.
-
nextObservation
public double nextObservation()
Generates and returns the next observation X(tj) of the stochastic process. The processes are usually sampled sequentially, i.e. if the last observation generated was for time tj-1, the next observation returned will be for time tj. In some cases, subclasses extending this abstract class may use non-sequential sampling algorithms (such as bridge sampling). The order of generation of the tj's is then specified by the subclass. All the processes generated using principal components analysis (PCA) do not have this method.
-
getCurrentObservationIndex
public int getCurrentObservationIndex()
Returns the value of the index j corresponding to the time tj of the last generated observation.
-
getCurrentObservation
public double getCurrentObservation()
Returns the value of the last generated observation X(tj).
-
getX0
public double getX0()
Returns the initial value X(t0) for this process.
-
setX0
public void setX0(double s0)
Sets the initial value X(t0) for this process to s0, and reinitializes.
-
setStream
public abstract void setStream(RandomStream stream)
Resets the random stream of the underlying generator to stream.
-
getStream
public abstract RandomStream getStream()
Returns the random stream of the underlying generator.
-
getArrayMappingCounterToIndex
public int[] getArrayMappingCounterToIndex()
Returns a reference to an array that maps an integer k to ik, the index of the observation S(tik) corresponding to the k-th observation to be generated for a sample path of this process. If this process is sampled sequentially, then this map is trivial (i.e. ik = k). But it can be useful in a more general setting where the process is not sampled sequentially (for example, by a Brownian or gamma bridge) and one wants to know which observations of the current sample path were previously generated or will be generated next.
-
-
DMelt 3.0 © DataMelt by jWork.ORG