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

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


      // Simply make a list (0,1,..N-1) and randomize it, seeded with "p".
      // Note that this is perhaps not what you want...
      for (int i = N; --i >= 0;) {
        permutation[i] = i;
      }
      Uniform gen = new Uniform(new MersenneTwister((int) p));
      for (int i = 0; i < N - 1; i++) {
        int random = gen.nextIntFromTo(i, N - 1);

        //swap(i, random)
        int tmp = permutation[random];
        permutation[random] = permutation[i];
        permutation[i] = tmp;
View Full Code Here


   */
  public WeightedRandomSampler(int weight, RandomEngine randomGenerator) {
    if (randomGenerator == null) {
      randomGenerator = org.apache.mahout.math.jet.random.AbstractDistribution.makeDefaultGenerator();
    }
    this.generator = new Uniform(randomGenerator);
    setWeight(weight);
  }
View Full Code Here

   */
  public WeightedRandomSampler(int weight, Random randomGenerator) {
    if (randomGenerator == null) {
      randomGenerator = RandomUtils.getRandom();
    }
    this.generator = new Uniform(randomGenerator);
    setWeight(weight);
  }
View Full Code Here

    @Test
    public void testUniform() {
        Random gen = RandomUtils.getRandom();
        for (int i = 0; i < repeats(); i++) {
            runTest(new Uniform(0, 1, gen), 100,
                    new double[]{0.001, 0.01, 0.1, 0.5, 0.9, 0.99, 0.999},
                    "uniform", true, gen);
        }
    }
View Full Code Here

        // this mixture of a uniform and normal distribution has a very narrow peak which is centered
        // near the median.  Our system should be scale invariant and work well regardless.
        final Random gen = RandomUtils.getRandom();
        AbstractContinousDistribution mix = new AbstractContinousDistribution() {
            AbstractContinousDistribution normal = new Normal(0, 1e-5, gen);
            AbstractContinousDistribution uniform = new Uniform(-1, 1, gen);

            @Override
            public double nextDouble() {
                double x;
                if (gen.nextDouble() < 0.5) {
                    x = uniform.nextDouble();
                } else {
                    x = normal.nextDouble();
                }
                return x;
            }
View Full Code Here

    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

    @Test
    public void testUniform() {
        RandomWrapper gen = RandomUtils.getRandom();
        for (int i = 0; i < 5; i++) {
            runTest(new Uniform(0, 1, gen), 100,
//                    new double[]{0.0001, 0.001, 0.01, 0.1, 0.5, 0.9, 0.99, 0.999, 0.9999},
                    new double[]{0.001, 0.01, 0.1, 0.5, 0.9, 0.99, 0.999},
                    "uniform", true);
        }
    }
View Full Code Here

        // this mixture of a uniform and normal distribution has a very narrow peak which is centered
        // near the median.  Our system should be scale invariant and work well regardless.
        final RandomWrapper gen = RandomUtils.getRandom();
        AbstractContinousDistribution mix = new AbstractContinousDistribution() {
            AbstractContinousDistribution normal = new Normal(0, 1e-5, gen);
            AbstractContinousDistribution uniform = new Uniform(-1, 1, gen);

            @Override
            public double nextDouble() {
                double x;
                if (gen.nextDouble() < 0.5) {
                    x = uniform.nextDouble();
                } else {
                    x = normal.nextDouble();
                }
                return x;
            }
View Full Code Here

    }

    @SuppressWarnings("UnusedDeclaration")
    public void setStart(String start) throws ParseException {
        this.start = df.parse(start).getTime();
        base = new Uniform(0, this.end - this.start, RandomUtils.getRandom());
    }
View Full Code Here

    }

    @SuppressWarnings("UnusedDeclaration")
    public void setEnd(String end) throws ParseException {
        this.end = df.parse(end).getTime();
        base = new Uniform(0, this.end - this.start, RandomUtils.getRandom());
    }
View Full Code Here

TOP

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

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.