List of usage examples for org.apache.mahout.math.jet.random Uniform Uniform
public Uniform(double min, double max, Random randomGenerator)
From source file:com.clearspring.analytics.stream.quantile.TDigestTest.java
License:Apache License
@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); }/*from w ww . ja v a 2 s. co m*/ }
From source file:com.clearspring.analytics.stream.quantile.TDigestTest.java
License:Apache License
@Test public void testNarrowNormal() { // 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//from ww w .ja va2s .c o m public double nextDouble() { double x; if (gen.nextDouble() < 0.5) { x = uniform.nextDouble(); } else { x = normal.nextDouble(); } return x; } }; for (int i = 0; i < repeats(); i++) { runTest(mix, 100, new double[] { 0.001, 0.01, 0.1, 0.3, 0.5, 0.7, 0.9, 0.99, 0.999 }, "mixture", false, gen); } }
From source file:com.clearspring.analytics.stream.quantile.TDigestTest.java
License:Apache License
@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); }// w w w. j a va2s .com }
From source file:com.mapr.synth.samplers.DateSampler.java
License:Apache License
@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()); }
From source file:com.mapr.synth.samplers.DateSampler.java
License:Apache License
@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()); }
From source file:com.tdunning.math.stats.ArrayDigestTest.java
License:Apache License
@Test public void testUniform() { Random gen = RandomUtils.getRandom(); for (int i = 0; i < repeats(); i++) { runTest(factory, new Uniform(0, 1, gen), 100, new double[] { 0.001, 0.01, 0.1, 0.5, 0.9, 0.99, 0.999 }, "uniform", true); }//from www . j ava 2 s. c o m }
From source file:com.tdunning.math.stats.ArrayDigestTest.java
License:Apache License
@Test public void testNarrowNormal() { // 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//from w w w . j a v a2s. c om public double nextDouble() { double x; if (gen.nextDouble() < 0.5) { x = uniform.nextDouble(); } else { x = normal.nextDouble(); } return x; } }; for (int i = 0; i < repeats(); i++) { runTest(factory, mix, 100, new double[] { 0.001, 0.01, 0.1, 0.3, 0.5, 0.7, 0.9, 0.99, 0.999 }, "mixture", false); } }
From source file:com.tdunning.math.stats.ArrayDigestTest.java
License:Apache License
@Test public void compareToQDigest() throws FileNotFoundException { Random rand = RandomUtils.getRandom(); PrintWriter out = new PrintWriter(new FileOutputStream("qd-array-comparison.csv")); try {//w ww . java2 s. c o m out.printf("tag\tcompression\tq\te1\tcdf.vs.q\tsize\tqd.size\n"); for (int i = 0; i < repeats(); i++) { compareQD(out, new Gamma(0.1, 0.1, rand), "gamma", 1L << 48); compareQD(out, new Uniform(0, 1, rand), "uniform", 1L << 48); } } finally { out.close(); } }
From source file:com.tdunning.math.stats.ArrayDigestTest.java
License:Apache License
@Test public void compareToStreamingQuantile() throws FileNotFoundException { Random rand = RandomUtils.getRandom(); PrintWriter out = new PrintWriter(new FileOutputStream("sk-array-comparison.csv")); try {//from w w w. j a v a2 s.com out.printf("tag\tcompression\tq\te1\tcdf.vs.q\tsize\tsk.size\n"); for (int i = 0; i < repeats(); i++) { compareSQ(out, new Gamma(0.1, 0.1, rand), "gamma", 1L << 48); compareSQ(out, new Uniform(0, 1, rand), "uniform", 1L << 48); } } finally { out.close(); } }
From source file:com.tdunning.math.stats.AVLTreeDigestTest.java
License:Apache License
@Test public void compareToQDigest() throws FileNotFoundException { Random rand = RandomUtils.getRandom(); PrintWriter out = new PrintWriter(new FileOutputStream("qd-tree-comparison.csv")); try {//from www . ja v a2 s . co m for (int i = 0; i < repeats(); i++) { compareQD(out, new Gamma(0.1, 0.1, rand), "gamma", 1L << 48); compareQD(out, new Uniform(0, 1, rand), "uniform", 1L << 48); } } finally { out.close(); } }