List of usage examples for org.apache.mahout.math.jet.random Gamma Gamma
public Gamma(double alpha, double rate, Random randomGenerator)
From source file:com.clearspring.analytics.stream.quantile.TDigestTest.java
License:Apache License
@Test public void testGamma() { // this Gamma distribution is very heavily skewed. The 0.1%-ile is 6.07e-30 while // 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); }/*from w w w .java 2 s . co m*/ }
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); }//from ww w .ja va 2 s. c om }
From source file:com.mapr.stats.BetaDistribution.java
License:Apache License
public BetaDistribution(double alpha, double beta, Random random) { this.alpha = alpha; this.beta = beta; gAlpha = new Gamma(alpha, 1, random); gBeta = new Gamma(beta, 1, random); }
From source file:com.mapr.synth.samplers.Changer.java
License:Apache License
public Changer(@JsonProperty("values") List<FieldSampler> fields) { this.fields = fields; fieldNames = Lists.newArrayList();//from www . java 2 s.c om for (FieldSampler field : fields) { fieldNames.add(field.getName()); } x = new Gamma(1, 1, gen); y = new Gamma(3, 1, gen); }
From source file:com.mapr.synth.samplers.Changer.java
License:Apache License
@SuppressWarnings("UnusedDeclaration") public void setSkew(double skew) { if (skew < 0) { x = new Gamma(skew, 1, gen); y = new Gamma(1, 1, gen); } else {/*w w w .j av a 2 s. com*/ x = new Gamma(1, 1, gen); y = new Gamma(skew, 1, gen); } }
From source file:com.mapr.synth.samplers.GammaSampler.java
License:Apache License
private void init() { double a, b;//from w w w . j a va 2 s . co m if (Double.isNaN(alpha) && Double.isNaN(beta) && !Double.isNaN(dof)) { if (Double.isNaN(scale)) { scale = 1; } a = dof / 2; b = scale * dof / 2; } else if (Double.isNaN(dof) && !Double.isNaN(alpha) && !Double.isNaN(beta)) { a = alpha; 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()); } }
From source file:com.tdunning.math.stats.ArrayDigestTest.java
License:Apache License
@Test public void testGamma() { // this Gamma distribution is very heavily skewed. The 0.1%-ile is 6.07e-30 while // 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 < 10; 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", false); }/*from w ww .j av a2 s . co m*/ }
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 {// ww w. j a v a2 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 av a 2 s . c o m*/ 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 testGamma() { // this Gamma distribution is very heavily skewed. The 0.1%-ile is 6.07e-30 while // 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); }//from w w w . ja v a 2 s.com }