@Test public void consistency() { Random gen = RandomUtils.getRandom(); double offset = 0; double scale = 1; Normal dist = new Normal(offset, scale, RandomUtils.getRandom()); for (int k = 0; k < 20; k++) { dist.setState(offset, scale); DistributionChecks.checkDistribution(dist, breaks, offset, scale, 10000); offset = gen.nextGaussian(); scale = Math.exp(3 * gen.nextGaussian()); } }
@Test public void testSetState() throws Exception { Normal dist = new Normal(0, 1, RandomUtils.getRandom()); dist.setState(1.3, 5.9); DistributionChecks.checkDistribution(dist, breaks, 1.3, 5.9, 10000); }
@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); } }
@Test public void consistency() throws Exception { Random gen = RandomUtils.getRandom(); double offset = 0; double scale = 1; Normal dist = new Normal(offset, scale, RandomUtils.getRandom()); for (int k = 0; k < 20; k++) { dist.setState(offset, scale); DistributionChecks.checkDistribution(dist, breaks, offset, scale, 10000); offset = gen.nextGaussian(); scale = Math.exp(3 * gen.nextGaussian()); } }
@Test public void testSetState() throws Exception { Normal dist = new Normal(0, 1, RandomUtils.getRandom()); dist.setState(1.3, 5.9); DistributionChecks.checkDistribution(dist, breaks, 1.3, 5.9, 10000); }
@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); } }