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

Examples of org.apache.mahout.math.jet.random.Gamma


        // the median is 0.006 and the 99.9th %-ile is 33.6 while the mean is 1.
        // this severe skew means that we have to have positional accuracy that
        // varies by over 11 orders of magnitude.
        Random gen = RandomUtils.getRandom();
        for (int i = 0; i < repeats(); i++) {
            runTest(new Gamma(0.1, 0.1, gen), 100,
//                    new double[]{6.0730483624079e-30, 6.0730483624079e-20, 6.0730483627432e-10, 5.9339110446023e-03,
//                            2.6615455373884e+00, 1.5884778179295e+01, 3.3636770117188e+01},
                    new double[]{0.001, 0.01, 0.1, 0.5, 0.9, 0.99, 0.999},
                    "gamma", true, gen);
        }
View Full Code Here


    @Test
    public void compareToQDigest() {
        Random rand = RandomUtils.getRandom();

        for (int i = 0; i < repeats(); i++) {
            compare(new Gamma(0.1, 0.1, rand), "gamma", 1L << 48, rand);
            compare(new Uniform(0, 1, rand), "uniform", 1L << 48, rand);
        }
    }
View Full Code Here

  }

  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

        // the median is 0.006 and the 99.9th %-ile is 33.6 while the mean is 1.
        // this severe skew means that we have to have positional accuracy that
        // varies by over 11 orders of magnitude.
        RandomWrapper gen = RandomUtils.getRandom();
        for (int i = 0; i < 5; i++) {
            runTest(new Gamma(0.1, 0.1, gen), 100,
//                    new double[]{6.0730483624079e-30, 6.0730483624079e-20, 6.0730483627432e-10, 5.9339110446023e-03,
//                            2.6615455373884e+00, 1.5884778179295e+01, 3.3636770117188e+01},
                    new double[]{0.001, 0.01, 0.1, 0.5, 0.9, 0.99, 0.999},
                    "gamma", true);
        }
View Full Code Here

            b = beta;
        } else {
            throw new IllegalArgumentException("Must use either alpha,beta,rate (or defaults) or dof,scale to parametrize gamma");
        }
        if (seed != SEED_NOT_SET) {
            rand = new Gamma(a, b, new Random(seed));
        } else {
            rand = new Gamma(a, b, new Random());
        }
    }
View Full Code Here


  @Test(timeout=50000)
  public void testTimesSparseEfficiency() {
    Random raw = RandomUtils.getRandom();
    Gamma gen = new Gamma(0.1, 0.1, raw);

    // 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]);
        }
      }
    }

    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

  }

  @Test(timeout=50000)
  public void testTimesDenseEfficiency() {
    Random raw = RandomUtils.getRandom();
    Gamma gen = new Gamma(0.1, 0.1, raw);

    // 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

  }

  @Test(timeout=50000)
  public void testTimesOtherSparseEfficiency() {
    Random raw = RandomUtils.getRandom();
    Gamma gen = new Gamma(0.1, 0.1, raw);

    // 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

        // the median is 0.006 and the 99.9th %-ile is 33.6 while the mean is 1.
        // this severe skew means that we have to have positional accuracy that
        // varies by over 11 orders of magnitude.
        Random gen = RandomUtils.getRandom();
        for (int i = 0; i < repeats(); i++) {
            runTest(factory, new Gamma(0.1, 0.1, gen), 100,
//                    new double[]{6.0730483624079e-30, 6.0730483624079e-20, 6.0730483627432e-10, 5.9339110446023e-03,
//                            2.6615455373884e+00, 1.5884778179295e+01, 3.3636770117188e+01},
                    new double[]{0.001, 0.01, 0.1, 0.5, 0.9, 0.99, 0.999},
                    "gamma", true);
        }
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.jet.random.Gamma

Copyright © 2018 www.massapicom. 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.