Package org.apache.mahout.math.jet.random.engine

Examples of org.apache.mahout.math.jet.random.engine.RandomEngine.raw()


      RandomEngine rand = this.randomGenerator;
      do {
        double y;
        do {
          y = Math.tan(Math.PI * rand.raw());
          em = sq * y + xm;
        } while (em < 0.0);
        em = (double) (int) (em); // faster than em = Math.floor(em); (em>=0.0)
        t = 0.9 * (1.0 + y * y) * Math.exp(em * alxm - logGamma(em + 1.0) - g);
      } while (rand.raw() > t);
View Full Code Here


          y = Math.tan(Math.PI * rand.raw());
          em = sq * y + xm;
        } while (em < 0.0);
        em = (double) (int) (em); // faster than em = Math.floor(em); (em>=0.0)
        t = 0.9 * (1.0 + y * y) * Math.exp(em * alxm - logGamma(em + 1.0) - g);
      } while (rand.raw() > t);
      return (int) em;
    } else { // mean is too large
      return (int) xm;
    }
  }
View Full Code Here

        p0 = p;
        //for (k=pp.length; --k >=0; ) pp[k] = 0;
      }
      m = (my > 1.0) ? (int) my : 1;
      while (true) {
        double u = gen.raw();
        int k = 0;
        if (u <= p0) {
          return (k);
        }
        if (llll != 0) {              // Step T. Table comparison
View Full Code Here

        double V;
        double U;
        int Y;
        int X;
        int Dk;
        if ((U = gen.raw() * p6) < p2) {         // centre left

          // immediate acceptance region R2 = [k2, m) *[0, f2),  X = k2, ... m -1
          if ((V = U - p1) < 0.0) {
            return (k2 + (int) (U / f2));
          }
View Full Code Here

            return (k1 + (int) (V / f1));
          }

          // computation of candidate X < k2, and its counterpart Y > k2
          // either squeeze-acceptance of X or acceptance-rejection of Y
          Dk = (int) (dl * gen.raw()) + 1;
          if (W <= f2 - Dk * (f2 - f2 / r2)) {            // quick accept of
            return (k2 - Dk);                          // X = k2 - Dk
          }
          if ((V = f2 + f2 - W) < 1.0) {                // quick reject of Y
            Y = k2 + Dk;
View Full Code Here

            return (k5 - (int) (V / f5));
          }

          // computation of candidate X > k4, and its counterpart Y < k4
          // either squeeze-acceptance of X or acceptance-rejection of Y
          Dk = (int) (dr * gen.raw()) + 1;
          if (W <= f4 - Dk * (f4 - f4 * r4)) {             // quick accept of
            return (k4 + Dk);                           // X = k4 + Dk
          }
          if ((V = f4 + f4 - W) < 1.0) {                 // quick reject of Y
            Y = k4 - Dk;
View Full Code Here

              return (Y);
            }    // final accept of Y
          }
          X = k4 + Dk;
        } else {
          W = gen.raw();
          if (U < p5) {                                  // expon. tail left
            Dk = (int) (1.0 - Math.log(W) / ll);
            if ((X = k1 - Dk) < 0) {
              continue;
            }          // 0 <= X <= k1 - 1
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.