Empirical extends AbstractSamplerFunction { @Override public Double sample() { return sample(gen.nextDouble()); } Empirical(boolean exceedMinimum, boolean exceedMaximum, int samples, double... ecdf); @Override Double sample(); double sample(double u);  }
@Test public void testSimpleDist() { RandomUtils.useTestSeed(); Empirical z = new Empirical(true, true, 3, 0, 1, 0.5, 2, 1, 3.0); List<Double> r = Lists.newArrayList(); for (int i = 0; i < 10001; i++) { r.add(z.sample()); } Collections.sort(r); assertEquals(2.0, r.get(5000), 0.15); }
@Test public void testZeros() { Empirical z = new Empirical(true, true, 3, 0, 1, 0.5, 2, 1, 3.0); assertEquals(-16.52, z.sample(0), 1.0e-2); assertEquals(20.47, z.sample(1), 1.0e-2); }