protected void initArrays(int d) {
   double dt;
   for (int j = 0; j < d; j++) {
     dt = t[j + 1] - t[j];
     alphadt[j] = alpha * (dt);
     sigmasqrdt[j] = sigma * Math.sqrt(dt);
   }
 }
Exemple #2
0
 // This is called by setObservationTimes to precompute constants
 // in order to speed up the path generation.
 protected void init() {
   super.init();
   mudt = new double[d];
   sigmasqrdt = new double[d];
   for (int j = 0; j < d; j++) {
     double dt = t[j + 1] - t[j];
     mudt[j] = mu * dt;
     sigmasqrdt[j] = sigma * Math.sqrt(dt);
   }
 }
 /**
  * Generates and returns the next observation at time @f$t_{j+1} =@f$ `nextTime`. Assumes the
  * previous observation time is @f$t_j@f$ defined earlier (either by this method or by
  * <tt>setObservationTimes</tt>), as well as the value of the previous observation @f$X(t_j)@f$.
  * *Warning*: This method will reset the observations time @f$t_{j+1}@f$ for this process to
  * `nextTime`. The user must make sure that the @f$t_{j+1}@f$ supplied is @f$\geq t_j@f$.
  */
 public double nextObservation(double nextTime) {
   double previousTime = t[observationIndex];
   double xOld = path[observationIndex];
   observationIndex++;
   t[observationIndex] = nextTime;
   double dt = nextTime - previousTime;
   double x = xOld + alpha * (beta - xOld) * dt + sigma * Math.sqrt(dt) * gen.nextDouble();
   path[observationIndex] = x;
   return x;
 }
Exemple #4
0
 /**
  * Generates and returns the next observation at time @f$t_{j+1} =@f$ `nextTime`. It uses the
  * previous observation time @f$t_j@f$ defined earlier (either by this method or by
  * <tt>setObservationTimes</tt>), as well as the value of the previous observation @f$X(t_j)@f$.
  * *Warning*: This method will reset the observations time @f$t_{j+1}@f$ for this process to
  * `nextTime`. The user must make sure that the @f$t_{j+1}@f$ supplied is @f$\geq t_j@f$.
  */
 public double nextObservation(double nextTime) {
   // This method is useful for generating variance gamma processes
   double x = path[observationIndex];
   double previousTime = t[observationIndex];
   observationIndex++;
   t[observationIndex] = nextTime;
   double dt = nextTime - previousTime;
   x += mu * dt + sigma * Math.sqrt(dt) * gen.nextDouble();
   path[observationIndex] = x;
   return x;
 }
Exemple #5
0
 /**
  * Generates an observation of the process in `dt` time units, assuming that the process has
  * value @f$x@f$ at the current time. Uses the process parameters specified in the constructor.
  * Note that this method does not affect the sample path of the process stored internally (if
  * any).
  */
 public double nextObservation(double x, double dt) {
   x += mu * dt + sigma * Math.sqrt(dt) * gen.nextDouble();
   return x;
 }
 /**
  * Generates and returns an observation of the process in `dt` time units, assuming that the
  * process has value @f$x@f$ at the current time. Uses the process parameters specified in the
  * constructor. Note that this method does not affect the sample path of the process stored
  * internally (if any).
  */
 public double nextObservation(double x, double dt) {
   x = x + alpha * (beta - x) * dt + sigma * Math.sqrt(dt) * gen.nextDouble();
   return x;
 }