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

Examples of org.apache.mahout.math.jet.random.Gamma.nextDouble()


  private static OnlineSummarizer gamma(int n, double shape) {
    OnlineSummarizer x = new OnlineSummarizer();
    Random gen = RandomUtils.getRandom();
    AbstractContinousDistribution gamma = new Gamma(shape, shape, gen);
    for (int i = 0; i < n; i++) {
      x.add(gamma.nextDouble());
    }
    return x;
  }

}
View Full Code Here


    // build two large sequential sparse matrices and multiply them
    Matrix x = new SparseRowMatrix(1000, 2000, false);
    for (int i = 0; i < 1000; i++) {
      int[] values = new int[1000];
      for (int k = 0; k < 1000; k++) {
        int j = (int) Math.min(1000, gen.nextDouble());
        values[j]++;
      }
      for (int j = 0; j < 1000; j++) {
        if (values[j] > 0) {
          x.set(i, j, values[j]);
View Full Code Here

    Matrix y = new SparseRowMatrix(2000, 1000, false);
    for (int i = 0; i < 2000; i++) {
      int[] values = new int[1000];
      for (int k = 0; k < 1000; k++) {
        int j = (int) Math.min(1000, gen.nextDouble());
        values[j]++;
      }
      for (int j = 0; j < 1000; j++) {
        if (values[j] > 0) {
          y.set(i, j, values[j]);
View Full Code Here

    // build a sequential sparse matrix and a dense matrix and multiply them
    Matrix x = new SparseRowMatrix(1000, 2000, false);
    for (int i = 0; i < 1000; i++) {
      int[] values = new int[1000];
      for (int k = 0; k < 1000; k++) {
        int j = (int) Math.min(1000, gen.nextDouble());
        values[j]++;
      }
      for (int j = 0; j < 1000; j++) {
        if (values[j] > 0) {
          x.set(i, j, values[j]);
View Full Code Here

    // build a sequential sparse matrix and a diagonal matrix and multiply them
    Matrix x = new SparseRowMatrix(1000, 2000, false);
    for (int i = 0; i < 1000; i++) {
      int[] values = new int[1000];
      for (int k = 0; k < 1000; k++) {
        int j = (int) Math.min(1000, gen.nextDouble());
        values[j]++;
      }
      for (int j = 0; j < 1000; j++) {
        if (values[j] > 0) {
          x.set(i, j, values[j]);
View Full Code Here

  private static double[] gamma(int n, double shape) {
    double[] r = new double[n];
    Random gen = RandomUtils.getRandom();
    AbstractContinousDistribution gamma = new Gamma(shape, shape, gen);
    for (int i = 0; i < n; i++) {
      r[i] = gamma.nextDouble();
    }
    return r;
  }
}
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.