StochasticSuppliers { public static StochasticSupplier<Integer> uniformInt(int lower, int upper) { return new IntegerDistributionSS(new UniformIntegerDistribution( new MersenneTwister(), lower, upper)); } private  StochasticSuppliers(); static StochasticSupplier<T> constant(T value); static boolean isConstant(StochasticSupplier<T> supplier); static StochasticSupplier<T> empty(String errorMsg); static StochasticSupplier<T> checked(
      StochasticSupplier<T> supplier,
      Predicate<T> predicate); static StochasticSupplier<T> fromIterable(Iterable<T> iter); static StochasticSupplier<T> fromSupplier(Supplier<T> supplier); static Builder normal(); static StochasticSupplier<Double> uniformDouble(double lower,
      double upper); static StochasticSupplier<Integer> uniformInt(int lower, int upper); static StochasticSupplier<Long> uniformLong(int lower, int upper); static StochasticSupplier<Long> intToLong(
      StochasticSupplier<Integer> supplier); static StochasticSupplier<Integer> roundDoubleToInt(
      StochasticSupplier<Double> supplier); static StochasticSupplier<Long> roundDoubleToLong(
      StochasticSupplier<Double> supplier); static StochasticSupplier<MersenneTwister> mersenneTwister();  }
@Test public void testUniform() { final RandomGenerator rng = new MersenneTwister(123L); final StochasticSupplier<Integer> sup = uniformInt(2, 10); final IntegerDistribution id = new UniformIntegerDistribution(2, 10); final Multiset<Integer> ms = TreeMultiset.create(); for (int i = 0; i < 1000; i++) { ms.add(sup.get(rng.nextLong())); } final List<Integer> observations = newArrayList(); final List<Double> expectations = newArrayList(); for (final Multiset.Entry<Integer> entry : ms.entrySet()) { observations.add(entry.getCount()); expectations.add(id.probability(entry.getElement())); } assertTrue(chiSquare(expectations, observations, .01)); }