/** * Generates a random value from the {@link PascalDistribution Pascal Distribution}. * * @param r the number of successes of the Pascal distribution * @param p the probability of success of the Pascal distribution * @return random value sampled from the Pascal(r, p) distribution * @throws NotStrictlyPositiveException if the number of successes is not positive * @throws OutOfRangeException if the probability of success is not in the * range {@code [0, 1]}. */ public int nextPascal(int r, double p) throws NotStrictlyPositiveException, OutOfRangeException { return new PascalDistribution(getRandomGenerator(), r, p).sample(); }
public SamplingIterator(RandomWrapper random, Iterator<? extends T> delegate, double samplingRate) { Preconditions.checkNotNull(delegate); Preconditions.checkArgument(samplingRate > 0.0 && samplingRate <= 1.0, "Must be: 0.0 < samplingRate <= 1.0. But samplingRate = " + samplingRate); // Geometric distribution is special case of negative binomial (aka Pascal) with r=1: geometricDistribution = new PascalDistribution(random.getRandomGenerator(), 1, samplingRate); this.delegate = delegate; }
public SamplingIterator(RandomWrapper random, Iterator<? extends T> delegate, double samplingRate) { Preconditions.checkNotNull(delegate); Preconditions.checkArgument(samplingRate > 0.0 && samplingRate <= 1.0, "Must be: 0.0 < samplingRate <= 1.0. But samplingRate = " + samplingRate); // Geometric distribution is special case of negative binomial (aka Pascal) with r=1: geometricDistribution = new PascalDistribution(random.getRandomGenerator(), 1, samplingRate); this.delegate = delegate; }
public SamplingIterator(RandomWrapper random, Iterator<? extends T> delegate, double samplingRate) { Preconditions.checkNotNull(delegate); Preconditions.checkArgument(samplingRate > 0.0 && samplingRate <= 1.0, "Must be: 0.0 < samplingRate <= 1.0. But samplingRate = " + samplingRate); // Geometric distribution is special case of negative binomial (aka Pascal) with r=1: geometricDistribution = new PascalDistribution(random.getRandomGenerator(), 1, samplingRate); this.delegate = delegate; }
public SamplingLongPrimitiveIterator(RandomGenerator random, LongPrimitiveIterator delegate, double samplingRate) { Preconditions.checkNotNull(random); Preconditions.checkNotNull(delegate); Preconditions.checkArgument(samplingRate > 0.0 && samplingRate <= 1.0); // Geometric distribution is special case of negative binomial (aka Pascal) with r=1: geometricDistribution = new PascalDistribution(random, 1, samplingRate); this.delegate = delegate; this.hasNext = true; doNext(); }
public SamplingLongPrimitiveIterator(final RandomWrapper random, final LongPrimitiveIterator delegate, final double samplingRate) { Preconditions.checkNotNull(delegate); Preconditions.checkArgument(samplingRate > 0.0 && samplingRate <= 1.0, "Must be: 0.0 < samplingRate <= 1.0"); // Geometric distribution is special case of negative binomial (aka Pascal) with r=1: geometricDistribution = new PascalDistribution( random.getRandomGenerator(), 1, samplingRate); this.delegate = delegate; hasNext = true; doNext(); }
public SamplingLongPrimitiveIterator(RandomWrapper random, LongPrimitiveIterator delegate, double samplingRate) { Preconditions.checkNotNull(delegate); Preconditions.checkArgument(samplingRate > 0.0 && samplingRate <= 1.0, "Must be: 0.0 < samplingRate <= 1.0"); // Geometric distribution is special case of negative binomial (aka Pascal) with r=1: geometricDistribution = new PascalDistribution(random.getRandomGenerator(), 1, samplingRate); this.delegate = delegate; this.hasNext = true; doNext(); }
public SamplingLongPrimitiveIterator(RandomWrapper random, LongPrimitiveIterator delegate, double samplingRate) { Preconditions.checkNotNull(delegate); Preconditions.checkArgument(samplingRate > 0.0 && samplingRate <= 1.0, "Must be: 0.0 < samplingRate <= 1.0"); // Geometric distribution is special case of negative binomial (aka Pascal) with r=1: geometricDistribution = new PascalDistribution(random.getRandomGenerator(), 1, samplingRate); this.delegate = delegate; this.hasNext = true; doNext(); }
public SamplingLongPrimitiveIterator(RandomWrapper random, LongPrimitiveIterator delegate, double samplingRate) { Preconditions.checkNotNull(delegate); Preconditions.checkArgument(samplingRate > 0.0 && samplingRate <= 1.0, "Must be: 0.0 < samplingRate <= 1.0"); // Geometric distribution is special case of negative binomial (aka Pascal) with r=1: geometricDistribution = new PascalDistribution(random.getRandomGenerator(), 1, samplingRate); this.delegate = delegate; this.hasNext = true; doNext(); }
/** * Generates a random value from the {@link PascalDistribution Pascal Distribution}. * * @param r the number of successes of the Pascal distribution * @param p the probability of success of the Pascal distribution * @return random value sampled from the Pascal(r, p) distribution * @throws NotStrictlyPositiveException if the number of successes is not positive * @throws OutOfRangeException if the probability of success is not in the * range {@code [0, 1]}. */ public int nextPascal(int r, double p) throws NotStrictlyPositiveException, OutOfRangeException { return new PascalDistribution(getRandomGenerator(), r, p).sample(); }
/** * Generates a random value from the {@link PascalDistribution Pascal Distribution}. * * @param r the number of successes of the Pascal distribution * @param p the probability of success of the Pascal distribution * @return random value sampled from the Pascal(r, p) distribution * @throws NotStrictlyPositiveException if the number of successes is not positive * @throws OutOfRangeException if the probability of success is not in the * range {@code [0, 1]}. */ public int nextPascal(int r, double p) throws NotStrictlyPositiveException, OutOfRangeException { return new PascalDistribution(getRandomGenerator(), r, p).sample(); }
/** * @param param * number of successes * @param param2 * prob. of success * @return Pascal distribution */ protected PascalDistribution getPascalDistribution(int param, double param2) { if (pascal == null || pascal.getNumberOfSuccesses() != param || pascal.getProbabilityOfSuccess() != param2) { pascal = new PascalDistribution(param, param2); } return pascal; }
dist = new PascalDistribution(n, p);
pascalDistribution = new PascalDistribution(RandomManager.getRandom(), 1, p);
@Override public IntegerDistribution deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { JsonNode node = p.getCodec().readTree(p); String simpleName = node.get("distribution").asText(); switch (simpleName) { case "BinomialDistribution": return new BinomialDistribution(node.get("trials").asInt(), node.get("p").asDouble()); case "GeometricDistribution": return new GeometricDistribution(node.get("p").asDouble()); case "HypergeometricDistribution": return new HypergeometricDistribution(node.get("populationSize").asInt(), node.get("numberOfSuccesses").asInt(), node.get("sampleSize").asInt()); case "PascalDistribution": return new PascalDistribution(node.get("r").asInt(), node.get("p").asDouble()); case "PoissonDistribution": return new PoissonDistribution(node.get("p").asDouble()); case "UniformIntegerDistribution": return new UniformIntegerDistribution(node.get("lower").asInt(), node.get("upper").asInt()); case "ZipfDistribution": return new ZipfDistribution(node.get("numElements").asInt(), node.get("exponent").asDouble()); default: throw new RuntimeException("Unknown or not supported distribution: " + simpleName); } } }
@Override public IntegerDistribution deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { JsonNode node = p.getCodec().readTree(p); String simpleName = node.get("distribution").asText(); switch (simpleName) { case "BinomialDistribution": return new BinomialDistribution(node.get("trials").asInt(), node.get("p").asDouble()); case "GeometricDistribution": return new GeometricDistribution(node.get("p").asDouble()); case "HypergeometricDistribution": return new HypergeometricDistribution(node.get("populationSize").asInt(), node.get("numberOfSuccesses").asInt(), node.get("sampleSize").asInt()); case "PascalDistribution": return new PascalDistribution(node.get("r").asInt(), node.get("p").asDouble()); case "PoissonDistribution": return new PoissonDistribution(node.get("p").asDouble()); case "UniformIntegerDistribution": return new UniformIntegerDistribution(node.get("lower").asInt(), node.get("upper").asInt()); case "ZipfDistribution": return new ZipfDistribution(node.get("numElements").asInt(), node.get("exponent").asDouble()); default: throw new RuntimeException("Unknown or not supported distribution: " + simpleName); } } }