@Override public double nextGaussian() { return random.nextGaussian(); }
/** * @param features dimension of vector * @param random random number generator * @return vector whose direction from the origin is chosen uniformly at random, but which is not normalized */ public static float[] randomVectorF(int features, RandomGenerator random) { float[] vector = new float[features]; for (int i = 0; i < features; i++) { vector[i] = (float) random.nextGaussian(); } return vector; }
/** * @param size Length of random array. * @return an array of Gaussian random numbers. */ private double[] randn(int size) { final double[] randn = new double[size]; for (int i = 0; i < size; i++) { randn[i] = random.nextGaussian(); } return randn; }
/** Generate a random scalar with null mean and unit standard deviation. * @return a random scalar with null mean and unit standard deviation */ public double nextNormalizedDouble() { return generator.nextGaussian(); }
/** * {@inheritDoc} */ public synchronized double nextGaussian() { return wrapped.nextGaussian(); } }
/** {@inheritDoc} */ @Override public double sample() { return standardDeviation * random.nextGaussian() + mean; } }
/** * @param size Length of random array. * @return an array of Gaussian random numbers. */ private double[] randn(int size) { final double[] randn = new double[size]; for (int i = 0; i < size; i++) { randn[i] = random.nextGaussian(); } return randn; }
/** * Returns the next pseudorandom, Gaussian ("normally") distributed * <code>double</code> value with mean <code>0.0</code> and standard * deviation <code>1.0</code> from this random number generator's sequence. * * @return the next pseudorandom, Gaussian ("normally") distributed * <code>double</code> value with mean <code>0.0</code> and * standard deviation <code>1.0</code> from this random number * generator's sequence */ @Override public double nextGaussian() { return randomGenerator.nextGaussian(); }
/** {@inheritDoc} */ @Override public double sample() { final double n = random.nextGaussian(); return FastMath.exp(scale + shape * n); } }
@Override public double nextGaussian() { return getRandomGenerator().nextGaussian(); }
/** * @param size Number of rows. * @param popSize Population size. * @return a 2-dimensional matrix of Gaussian random numbers. */ private RealMatrix randn1(int size, int popSize) { final double[][] d = new double[size][popSize]; for (int r = 0; r < size; r++) { for (int c = 0; c < popSize; c++) { d[r][c] = random.nextGaussian(); } } return new Array2DRowRealMatrix(d, false); } }
/** * @param size Number of rows. * @param popSize Population size. * @return a 2-dimensional matrix of Gaussian random numbers. */ private RealMatrix randn1(int size, int popSize) { final double[][] d = new double[size][popSize]; for (int r = 0; r < size; r++) { for (int c = 0; c < popSize; c++) { d[r][c] = random.nextGaussian(); } } return new Array2DRowRealMatrix(d, false); } }
/** {@inheritDoc} */ public double[] nextVector() { final double[] v = new double[dimension]; // See http://mathworld.wolfram.com/SpherePointPicking.html for example. // Pick a point by choosing a standard Gaussian for each element, and then // normalizing to unit length. double normSq = 0; for (int i = 0; i < dimension; i++) { final double comp = rand.nextGaussian(); v[i] = comp; normSq += comp * comp; } final double f = 1 / FastMath.sqrt(normSq); for (int i = 0; i < dimension; i++) { v[i] *= f; } return v; } }
/** {@inheritDoc} */ public double nextGaussian(double mu, double sigma) throws NotStrictlyPositiveException { if (sigma <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.STANDARD_DEVIATION, sigma); } return sigma * getRandomGenerator().nextGaussian() + mu; }
/** {@inheritDoc} */ @Override public double[] sample() { final int dim = getDimension(); final double[] normalVals = new double[dim]; for (int i = 0; i < dim; i++) { normalVals[i] = random.nextGaussian(); } final double[] vals = samplingMatrix.operate(normalVals); for (int i = 0; i < dim; i++) { vals[i] += means[i]; } return vals; }
@Override public Pair<String,String> generate(int id, RandomGenerator random) { return new Pair<>(Integer.toString(id), id + "," + random.nextInt(100) + ',' + random.nextBoolean() + ',' + random.nextGaussian()); }
final double x = random.nextGaussian(); final double v = (1 + c * x) * (1 + c * x) * (1 + c * x);
final double u = random.nextDouble(); if (u <= p1) { final double n = random.nextGaussian(); x = n * FastMath.sqrt(lambda + halfDelta) - 0.5d; if (x > delta || x < -lambda) {
/** * @param size Length of random array. * @return an array of Gaussian random numbers. */ private double[] randn(int size) { final double[] randn = new double[size]; for (int i = 0; i < size; i++) { randn[i] = random.nextGaussian(); } return randn; }
/** Generate a random scalar with null mean and unit standard deviation. * @return a random scalar with null mean and unit standard deviation */ public double nextNormalizedDouble() { return generator.nextGaussian(); }