コード例 #1
0
  protected void init() {
    super.init();
    if (observationTimesSet) {

      // Quantities for gamma bridge process
      bMu2dtOverNuL = new double[d + 1];
      bMu2dtOverNuR = new double[d + 1];
      wIndexList = new int[3 * d];

      int[] ptIndex = new int[d + 1];
      int indexCounter = 0;
      int newIndex, oldLeft, oldRight;

      ptIndex[0] = 0;
      ptIndex[1] = d;

      mu2OverNu = mu * mu / nu;
      mu2dTOverNu = mu2OverNu * (t[d] - t[0]);

      for (int powOfTwo = 1; powOfTwo <= d / 2; powOfTwo *= 2) {
        /* Make room in the indexing array "ptIndex" */
        for (int j = powOfTwo; j >= 1; j--) {
          ptIndex[2 * j] = ptIndex[j];
        }

        /* Insert new indices and Calculate constants */
        for (int j = 1; j <= powOfTwo; j++) {
          oldLeft = 2 * j - 2;
          oldRight = 2 * j;
          newIndex = (int) (0.5 * (ptIndex[oldLeft] + ptIndex[oldRight]));

          bMu2dtOverNuL[newIndex] = mu * mu * (t[newIndex] - t[ptIndex[oldLeft]]) / nu;
          bMu2dtOverNuR[newIndex] = mu * mu * (t[ptIndex[oldRight]] - t[newIndex]) / nu;

          ptIndex[oldLeft + 1] = newIndex;
          wIndexList[indexCounter] = ptIndex[oldLeft];
          wIndexList[indexCounter + 1] = newIndex;
          wIndexList[indexCounter + 2] = ptIndex[oldRight];

          indexCounter += 3;
        }
      }
      /* Check if there are holes remaining and fill them */
      for (int k = 1; k < d; k++) {
        if (ptIndex[k - 1] + 1 < ptIndex[k]) {
          // there is a hole between (k-1) and k.

          bMu2dtOverNuL[ptIndex[k - 1] + 1] =
              mu * mu * (t[ptIndex[k - 1] + 1] - t[ptIndex[k - 1]]) / nu;
          bMu2dtOverNuR[ptIndex[k - 1] + 1] =
              mu * mu * (t[ptIndex[k]] - t[ptIndex[k - 1] + 1]) / nu;

          wIndexList[indexCounter] = ptIndex[k] - 2;
          wIndexList[indexCounter + 1] = ptIndex[k] - 1;
          wIndexList[indexCounter + 2] = ptIndex[k];
          indexCounter += 3;
        }
      }
    }
  }
コード例 #2
0
 /**
  * Resets the {@link umontreal.iro.lecuyer.rng.RandomStream RandomStream} of the {@link
  * umontreal.iro.lecuyer.randvar.GammaGen GammaGen} and the {@link
  * umontreal.iro.lecuyer.randvar.BetaGen BetaGen} to <TT>stream</TT>.
  */
 public void setStream(RandomStream stream) {
   super.setStream(stream);
   this.Bgen.setStream(stream);
   this.stream = stream;
 }