/** * Random normal using the given rng * * @param shape the shape of the ndarray * @param r the random generator to use * @return */ @Override public INDArray randn(int[] shape, org.nd4j.linalg.api.rng.Random r) { return r.nextGaussian(shape); }
@Override public INDArray randn(long[] shape, org.nd4j.linalg.api.rng.Random r) { return r.nextGaussian(shape); }
/** * {@inheritDoc} */ @Override public double sample() { if (means != null) throw new IllegalStateException("Unable to sample from more than one mean"); return standardDeviation * random.nextGaussian() + mean; }
/** * {@inheritDoc} */ @Override public double sample() { if (means != null) throw new IllegalStateException("Unable to sample from more than one mean"); return standardDeviation * random.nextGaussian() + mean; }
/** * {@inheritDoc} */ @Override public double sample() { if (means != null) throw new IllegalStateException("Unable to sample from more than one mean"); return standardDeviation * random.nextGaussian() + mean; }
/** * Generate a random normal N(0,1) with the specified order and shape * @param order Order of the output array * @param rows the number of rows in the matrix * @param columns the number of columns in the matrix * @return */ @Override public INDArray randn(char order, long rows, long columns) { return Nd4j.getRandom().nextGaussian(order, new long[] {rows, columns}); }
/** * Random normal using the current time stamp * as the seed * * @param shape the shape of the ndarray * @return */ @Override public INDArray randn(char order, int[] shape) { return Nd4j.getRandom().nextGaussian(order, shape); }
@Override public INDArray randn(char order, long[] shape) { return Nd4j.getRandom().nextGaussian(order, shape); }
@Override public INDArray sample(INDArray ret) { if (random.getStatePointer() != null) { if (means != null) { return Nd4j.getExecutioner().exec(new GaussianDistribution( ret, means, standardDeviation), random); } else { return Nd4j.getExecutioner().exec(new GaussianDistribution( ret, mean, standardDeviation), random); } } else { Iterator<long[]> idxIter = new NdIndexIterator(ret.shape()); //For consistent values irrespective of c vs. fortran ordering long len = ret.length(); if (means != null) { for (int i = 0; i < len; i++) { long[] idx = idxIter.next(); ret.putScalar(idx, standardDeviation * random.nextGaussian() + means.getDouble(idx)); } } else { for (int i = 0; i < len; i++) { ret.putScalar(idxIter.next(), standardDeviation * random.nextGaussian() + mean); } } return ret; } } }
/** * Random normal using the given rng * * @param shape the shape of the ndarray * @param r the random generator to use * @return */ @Override public INDArray randn(int[] shape, org.nd4j.linalg.api.rng.Random r) { return r.nextGaussian(shape); }
public double nextGaussian() { return nd4jRandom.nextGaussian(); }
public double nextGaussian(double mu, double sigma) { return nd4jRandom.nextGaussian() * sigma + mu; }
/** * {@inheritDoc} */ @Override public double sample() { if (means != null) throw new IllegalStateException("Unable to sample from more than one mean"); return standardDeviation * random.nextGaussian() + mean; }
/** * Generate a random normal N(0,1) with the specified order and shape * @param order Order of the output array * @param rows the number of rows in the matrix * @param columns the number of columns in the matrix * @return */ @Override public INDArray randn(char order, int rows, int columns) { return Nd4j.getRandom().nextGaussian(order, new int[] {rows, columns}); }
/** * Random normal using the current time stamp * as the seed * * @param shape the shape of the ndarray * @return */ @Override public INDArray randn(char order, int[] shape) { return Nd4j.getRandom().nextGaussian(order, shape); }
private INDArray doubleNextGaussian(long[] shape) { Nd4j.setDataType(bufferType); return nd4jRandom.nextGaussian(shape); }
@Override public INDArray sample(int[] shape) { if (random.getStatePointer() != null) { if (means != null) { return Nd4j.getExecutioner().exec(new GaussianDistribution( Nd4j.createUninitialized(shape, Nd4j.order()), means, standardDeviation), random); } else { return Nd4j.getExecutioner().exec(new GaussianDistribution( Nd4j.createUninitialized(shape, Nd4j.order()), mean, standardDeviation), random); } } else { INDArray ret = Nd4j.createUninitialized(shape, Nd4j.order()); Iterator<int[]> idxIter = new NdIndexIterator(shape); //For consistent values irrespective of c vs. fortran ordering int len = ret.length(); if (means != null) { for (int i = 0; i < len; i++) { int[] idx = idxIter.next(); ret.putScalar(idx, standardDeviation * random.nextGaussian() + means.getDouble(idx)); } } else { for (int i = 0; i < len; i++) { ret.putScalar(idxIter.next(), standardDeviation * random.nextGaussian() + mean); } } return ret; } } }