public IndianBuffet(double alpha, WordFunction<T> converter) { this.alpha = alpha; this.converter = converter; gen = RandomUtils.getRandom(); }
void resetToTestSeed() { setSeed(STANDARD_SEED); }
/** * Closes a {@link ResultSet}, {@link Statement} and {@link Connection} (if not null) and logs (but does not * rethrow) any resulting {@link SQLException}. This is useful for cleaning up after a database query. * * @param resultSet * {@link ResultSet} to close * @param statement * {@link Statement} to close * @param connection * {@link Connection} to close */ public static void quietClose(ResultSet resultSet, Statement statement, Connection connection) { quietClose(resultSet); quietClose(statement); quietClose(connection); }
public PoissonSampler(double lambda) { limit = 1; gen = RandomUtils.getRandom(); pd = new PoissonDistribution(gen.getRandomGenerator(), lambda, PoissonDistribution.DEFAULT_EPSILON, PoissonDistribution.DEFAULT_MAX_ITERATIONS); }
@Override @Before public void setUp() { RandomUtils.useTestSeed(); }
@Test public void testHashDouble() { assertEquals(new Double(0.0).hashCode(), RandomUtils.hashDouble(0.0)); assertEquals(new Double(1.0).hashCode(), RandomUtils.hashDouble(1.0)); assertEquals(new Double(Double.POSITIVE_INFINITY).hashCode(), RandomUtils.hashDouble(Double.POSITIVE_INFINITY)); assertEquals(new Double(Double.NaN).hashCode(), RandomUtils.hashDouble(Double.NaN)); }
@Test public void testNextTwinPrime() { assertEquals(5, RandomUtils.nextTwinPrime(-1)); assertEquals(5, RandomUtils.nextTwinPrime(1)); assertEquals(5, RandomUtils.nextTwinPrime(2)); assertEquals(5, RandomUtils.nextTwinPrime(3)); assertEquals(7, RandomUtils.nextTwinPrime(4)); assertEquals(7, RandomUtils.nextTwinPrime(5)); assertEquals(13, RandomUtils.nextTwinPrime(6)); assertEquals(RandomUtils.MAX_INT_SMALLER_TWIN_PRIME + 2, RandomUtils.nextTwinPrime(RandomUtils.MAX_INT_SMALLER_TWIN_PRIME)); try { RandomUtils.nextTwinPrime(RandomUtils.MAX_INT_SMALLER_TWIN_PRIME + 1); fail(); } catch (IllegalArgumentException iae) { // good } }
@Override public int hashCode() { return 31 * RandomUtils.hashDouble(weight) + value.hashCode(); } }
@Test public void testHashFloat() { assertEquals(new Float(0.0f).hashCode(), RandomUtils.hashFloat(0.0f)); assertEquals(new Float(1.0f).hashCode(), RandomUtils.hashFloat(1.0f)); assertEquals(new Float(Float.POSITIVE_INFINITY).hashCode(), RandomUtils.hashFloat(Float.POSITIVE_INFINITY)); assertEquals(new Float(Float.NaN).hashCode(), RandomUtils.hashFloat(Float.NaN)); }
public static void useTestSeed() { testSeed = true; synchronized (INSTANCES) { for (RandomWrapper rng : INSTANCES.keySet()) { rng.resetToTestSeed(); } } }
public static Random getRandom(long seed) { RandomWrapper random = new RandomWrapper(seed); INSTANCES.put(random, Boolean.TRUE); return random; }
public Missing(int seed, double p, Sampler<T> delegate, T missingMarker) { this.p = p; this.delegate = delegate; this.missingMarker = missingMarker; gen = RandomUtils.getRandom(seed); }
@Override @Before public void setUp() { RandomUtils.useTestSeed(); }
private MultiNormal(Matrix scale, Vector mean, int dimension) { gen = RandomUtils.getRandom(); this.dimension = dimension; this.scale = scale; this.mean = mean; }
@Override @Before public void setUp() { RandomUtils.useTestSeed(); }
/** * Constructs a uniform distribution with the given minimum and maximum, using a {@link * org.apache.mahout.math.jet.random.engine.MersenneTwister} seeded with the given seed. */ public Uniform(double min, double max, int seed) { this(min, max, RandomUtils.getRandom(seed)); }
@Before public void setUp() throws Exception { testTempDir = null; RandomUtils.useTestSeed(); }
/** * Generator for a matrix populated by random Gauissian values (Gaussian matrix view) * * @param seed The seed for the matrix. * @return Gaussian {@link IntIntFunction} generating matrix view with normal values */ public static IntIntFunction gaussianGenerator(final long seed) { final Random rnd = RandomUtils.getRandom(seed); return new IntIntFunction() { @Override public double apply(int first, int second) { rnd.setSeed(seed ^ (((long) first << 32) | (second & 0xffffffffL))); return rnd.nextGaussian(); } }; }
@Before public void testSetUp() { RandomUtils.useTestSeed(); }
@Before public void setUp() { RandomUtils.useTestSeed(); }