/** * {@inheritDoc} */ @Override public double sample() { final double u = random.nextDouble(); return u * upper + (1 - u) * lower; }
/** * Create a random ndarray with the given shape using the given rng * * @param shape the shape of the ndarray * @param r the random generator to use * @return the random ndarray with the specified shape */ @Override public INDArray rand(int[] shape, org.nd4j.linalg.api.rng.Random r) { INDArray ret = r.nextDouble(shape); return ret; }
@Override public INDArray rand(long[] shape, org.nd4j.linalg.api.rng.Random r) { INDArray ret = r.nextDouble(shape); return ret; }
/** * {@inheritDoc} * <p/> * The default implementation uses the * <a href="http://en.wikipedia.org/wiki/Inverse_transform_sampling"> * inversion method. * </a> */ @Override public double sample() { return inverseCumulativeProbability(random.nextDouble()); }
/** * Create a random ndarray with the given shape and order * * @param shape the shape of the ndarray * @return the random ndarray with the specified shape */ @Override public INDArray rand(char order, int[] shape) { return Nd4j.getRandom().nextDouble(order, shape); }
@Override public INDArray rand(char order, long[] shape) { return Nd4j.getRandom().nextDouble(order, shape); }
/** * Create a random (uniform 0-1) NDArray with the specified shape and order * @param order Order ('c' or 'f') of the output array * @param rows Number of rows of the output array * @param columns Number of columns of the output array */ @Override public INDArray rand(char order, long rows, long columns) { return Nd4j.getRandom().nextDouble(order, new long[] {rows, columns}); }
/** * {@inheritDoc} */ @Override public double sample() { final double u = random.nextDouble(); return u * upper + (1 - u) * lower; }
/** * Create a random ndarray with the given shape using the given rng * * @param shape the shape of the ndarray * @param r the random generator to use * @return the random ndarray with the specified shape */ @Override public INDArray rand(int[] shape, org.nd4j.linalg.api.rng.Random r) { INDArray ret = r.nextDouble(shape); return ret; }
public double nextDouble(double min, double max) { return nd4jRandom.nextDouble() * (max - min) + min; }
public double nextDouble() { return nd4jRandom.nextDouble(); }
/** * Generates a random integer between the specified numbers * @param begin the begin of the interval * @param end the end of the interval * @return an int between begin and end */ public static int randomNumberBetween(double begin, double end, org.nd4j.linalg.api.rng.Random rng) { if (begin > end) throw new IllegalArgumentException("Begin must not be less than end"); return (int) begin + (int) (rng.nextDouble() * ((end - begin) + 1)); }
/** * Create a random (uniform 0-1) NDArray with the specified shape and order * @param order Order ('c' or 'f') of the output array * @param rows Number of rows of the output array * @param columns Number of columns of the output array */ @Override public INDArray rand(char order, int rows, int columns) { return Nd4j.getRandom().nextDouble(order, new int[] {rows, columns}); }
/** * {@inheritDoc} * <p/> * The default implementation uses the * <a href="http://en.wikipedia.org/wiki/Inverse_transform_sampling"> * inversion method. * </a> */ @Override public double sample() { return inverseCumulativeProbability(random.nextDouble()); }
/** * Create a random ndarray with the given shape and order * * @param shape the shape of the ndarray * @return the random ndarray with the specified shape */ @Override public INDArray rand(char order, int[] shape) { return Nd4j.getRandom().nextDouble(order, shape); }
private INDArray doubleNextDouble(long[] shape) { Nd4j.setDataType(bufferType); return nd4jRandom.nextDouble(shape); }
/** * Takes an image and executes a pipeline of combined transforms. * * @param image to transform, null == end of stream * @param random object to use (or null for deterministic) * @return transformed image */ @Override public ImageWritable transform(ImageWritable image, Random random) { if (shuffle) Collections.shuffle(imageTransforms); // execute each item in the pipeline for (Pair<ImageTransform, Double> tuple : imageTransforms) { if (tuple.getSecond() == 1.0 || rng.nextDouble() < tuple.getSecond()) { // probability of execution image = tuple.getFirst().transform(image); } } return image; }