/** {@inheritDoc} */ public void setSeed(int[] seed) { rng.setSeed(convertToLong(seed)); }
/** * Sets the PRNG algorithm for the underlying SecureRandom instance using * the Security Provider API. The Security Provider API is defined in <a * href = * "http://java.sun.com/j2se/1.3/docs/guide/security/CryptoSpec.html#AppA"> * Java Cryptography Architecture API Specification & Reference.</a> * <p> * <strong>USAGE NOTE:</strong> This method carries <i>significant</i> * overhead and may take several seconds to execute. * </p> * * @param algorithm the name of the PRNG algorithm * @param provider the name of the provider * @throws NoSuchAlgorithmException if the specified algorithm is not available * @throws NoSuchProviderException if the specified provider is not installed */ public void setSecureAlgorithm(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException { secRand = RandomGeneratorFactory.createRandomGenerator(SecureRandom.getInstance(algorithm, provider)); }
/** {@inheritDoc} */ public void setSeed(int[] seed) { setSeed(RandomGeneratorFactory.convertToLong(seed)); } }
/** * Returns the SecureRandom used to generate secure random data. * <p> * Creates and initializes if null. Uses * {@code System.currentTimeMillis() + System.identityHashCode(this)} as the default seed. * </p> * * @return the SecureRandom used to generate secure random data, wrapped in a * {@link RandomGenerator}. */ private RandomGenerator getSecRan() { if (secRand == null) { secRand = RandomGeneratorFactory.createRandomGenerator(new SecureRandom()); secRand.setSeed(System.currentTimeMillis() + System.identityHashCode(this)); } return secRand; } }
/** {@inheritDoc} */ public void setSeed(int[] seed) { rng.setSeed(convertToLong(seed)); }
/** * Sets the PRNG algorithm for the underlying SecureRandom instance using * the Security Provider API. The Security Provider API is defined in <a * href = * "http://java.sun.com/j2se/1.3/docs/guide/security/CryptoSpec.html#AppA"> * Java Cryptography Architecture API Specification & Reference.</a> * <p> * <strong>USAGE NOTE:</strong> This method carries <i>significant</i> * overhead and may take several seconds to execute. * </p> * * @param algorithm the name of the PRNG algorithm * @param provider the name of the provider * @throws NoSuchAlgorithmException if the specified algorithm is not available * @throws NoSuchProviderException if the specified provider is not installed */ public void setSecureAlgorithm(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException { secRand = RandomGeneratorFactory.createRandomGenerator(SecureRandom.getInstance(algorithm, provider)); }
/** {@inheritDoc} */ public void setSeed(int[] seed) { rng.setSeed(convertToLong(seed)); }
/** * Returns the SecureRandom used to generate secure random data. * <p> * Creates and initializes if null. Uses * {@code System.currentTimeMillis() + System.identityHashCode(this)} as the default seed. * </p> * * @return the SecureRandom used to generate secure random data, wrapped in a * {@link RandomGenerator}. */ private RandomGenerator getSecRan() { if (secRand == null) { secRand = RandomGeneratorFactory.createRandomGenerator(new SecureRandom()); secRand.setSeed(System.currentTimeMillis() + System.identityHashCode(this)); } return secRand; } }
/** {@inheritDoc} */ public void setSeed(int[] seed) { setSeed(RandomGeneratorFactory.convertToLong(seed)); } }
public BM(int numClusters, int dimension, long randomSeed) { this.numClusters = numClusters; this.dimension = dimension; this.distributions = new BernoulliDistribution[numClusters][dimension]; this.mixtureCoefficients = new double[numClusters]; Arrays.fill(mixtureCoefficients,1.0/numClusters); this.logMixtureCoefficients = new double[numClusters]; Arrays.fill(logMixtureCoefficients,Math.log(1.0/numClusters)); Random random = new Random(randomSeed); RandomGenerator randomGenerator = RandomGeneratorFactory.createRandomGenerator(random); UniformRealDistribution uniform = new UniformRealDistribution(randomGenerator, 0.25,0.75); for (int k=0;k<numClusters;k++){ for (int d=0;d<dimension;d++){ double p = uniform.sample(); distributions[k][d] = new BernoulliDistribution(p); } } this.logClusterConditioinalForEmpty = new double[numClusters]; updateLogClusterConditioinalForEmpty(); this.names = new ArrayList<>(dimension); for (int d=0;d<dimension;d++){ names.add(""+d); } }
/** {@inheritDoc} */ public void setSeed(int[] seed) { setSeed(RandomGeneratorFactory.convertToLong(seed)); } }