@Test public void testPdf() { checkPdf(new Exponential(13.0, null), 13.0); }
@Test public void testToString() { assertEquals("org.apache.mahout.math.jet.random.Exponential(3.1000)", new Exponential(3.1, null).toString()); assertEquals("org.apache.mahout.math.jet.random.Exponential(3.1000)", new Exponential(3.1, null).toString()); } }
@Test public void testCdf() { Exponential dist = new Exponential(5.0, RandomUtils.getRandom()); for (int i = 0; i < 1000; i++) { double x = i / 50.0; assertEquals(1 - Math.exp(-x * 5.0), dist.cdf(x), 1.0e-9); } }
@Test public void testSetState() { Exponential dist = new Exponential(13.0, null); for (double lambda = 0.1; lambda < 1000; lambda *= 1.3) { dist.setState(lambda); checkPdf(dist, lambda); } }
@Test public void consistency() { Exponential dist = new Exponential(1, RandomUtils.getRandom()); // deciles computed using R double[] breaks = {0.1053605, 0.2231436, 0.3566749, 0.5108256, 0.6931472, 0.9162907, 1.2039728, 1.6094379, 2.3025851}; for (double lambda : new double[]{0.01, 0.1, 1, 2, 5, 100}) { dist.setState(lambda); DistributionChecks.checkDistribution(dist, breaks, 0, 1 / lambda, 10000); } } @Test
@Test public void testNextDouble() throws Exception { double[] x = { -0.01, 0.1053605, 0.2231436, 0.3566749, 0.5108256, 0.6931472, 0.9162907, 1.2039728, 1.6094379, 2.3025851 }; Exponential dist = new Exponential(1, RandomUtils.getRandom()); for (double lambda : new double[]{13.0, 0.02, 1.6}) { dist.setState(lambda); checkEmpiricalDistribution(dist, 10000, lambda); DistributionChecks.checkDistribution(dist, x, 0, 1 / lambda, 10000); } }
public User(InetAddress address, String geoCode, TermGenerator terms, double period) { this.terms = terms; this.geoCode = geoCode; this.address = address; this.rate = period; this.sessionTimeDistribution = new Exponential(period, RandomUtils.getRandom()); id = idCounter.addAndGet(1); nextSession = sessionTimeDistribution.nextDouble(); }
Exponential interval = new Exponential(1 / averageInterval, gen);
@Test public void testPdf() { checkPdf(new Exponential(13.0, null), 13.0); }
@Test public void testToString() { assertEquals("org.apache.mahout.math.jet.random.Exponential(3.1000)", new Exponential(3.1, null).toString()); assertEquals("org.apache.mahout.math.jet.random.Exponential(3.1000)", new Exponential(3.1, null).toString()); } }
@Test public void testCdf() { Exponential dist = new Exponential(5.0, RandomUtils.getRandom()); for (int i = 0; i < 1000; i++) { double x = i / 50.0; assertEquals(1 - Math.exp(-x * 5.0), dist.cdf(x), 1.0e-9); } }
@Test public void testSetState() { Exponential dist = new Exponential(13.0, null); for (double lambda = 0.1; lambda < 1000; lambda *= 1.3) { dist.setState(lambda); checkPdf(dist, lambda); } }
@Test public void consistency() throws Exception { Exponential dist = new Exponential(1, RandomUtils.getRandom()); // deciles computed using R double[] breaks = {0.1053605, 0.2231436, 0.3566749, 0.5108256, 0.6931472, 0.9162907, 1.2039728, 1.6094379, 2.3025851}; for (double lambda : new double[]{0.01, 0.1, 1, 2, 5, 100}) { dist.setState(lambda); DistributionChecks.checkDistribution(dist, breaks, 0, 1 / lambda, 10000); } } @Test
@Test public void testNextDouble() throws Exception { double[] x = { -0.01, 0.1053605, 0.2231436, 0.3566749, 0.5108256, 0.6931472, 0.9162907, 1.2039728, 1.6094379, 2.3025851 }; Exponential dist = new Exponential(1, RandomUtils.getRandom()); for (double lambda : new double[]{13.0, 0.02, 1.6}) { dist.setState(lambda); checkEmpiricalDistribution(dist, 10000, lambda); DistributionChecks.checkDistribution(dist, x, 0, 1 / lambda, 10000); } }
@Test public void copyLearnsAsExpected() { Random gen = RandomUtils.getRandom(); Exponential exp = new Exponential(0.5, gen); Vector beta = new DenseVector(200); for (Vector.Element element : beta.all()) {
Exponential exp = new Exponential(0.5, gen); Vector beta = new DenseVector(200); for (Vector.Element element : beta.all()) {