/** * 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(); }
/** * 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(); }
@Override protected T computeNext() { int toSkip = geometricDistribution.sample(); if (delegate instanceof SkippingIterator<?>) { SkippingIterator<? extends T> skippingDelegate = (SkippingIterator<? extends T>) delegate; skippingDelegate.skip(toSkip); if (skippingDelegate.hasNext()) { return skippingDelegate.next(); } } else { for (int i = 0; i < toSkip && delegate.hasNext(); i++) { delegate.next(); } if (delegate.hasNext()) { return delegate.next(); } } return endOfData(); }
@Override protected T computeNext() { int toSkip = geometricDistribution.sample(); if (delegate instanceof SkippingIterator<?>) { SkippingIterator<? extends T> skippingDelegate = (SkippingIterator<? extends T>) delegate; skippingDelegate.skip(toSkip); if (skippingDelegate.hasNext()) { return skippingDelegate.next(); } } else { for (int i = 0; i < toSkip && delegate.hasNext(); i++) { delegate.next(); } if (delegate.hasNext()) { return delegate.next(); } } return endOfData(); }
@Override protected T computeNext() { int toSkip = geometricDistribution.sample(); if (delegate instanceof SkippingIterator<?>) { SkippingIterator<? extends T> skippingDelegate = (SkippingIterator<? extends T>) delegate; skippingDelegate.skip(toSkip); if (skippingDelegate.hasNext()) { return skippingDelegate.next(); } } else { for (int i = 0; i < toSkip && delegate.hasNext(); i++) { delegate.next(); } if (delegate.hasNext()) { return delegate.next(); } } return endOfData(); }
private void doNext() { final int toSkip = geometricDistribution.sample(); delegate.skip(toSkip); if (delegate.hasNext()) { next = delegate.next(); } else { hasNext = false; } }
private void doNext() { int toSkip = geometricDistribution.sample(); delegate.skip(toSkip); if (delegate.hasNext()) { next = delegate.next(); } else { hasNext = false; } }
private void doNext() { int toSkip = geometricDistribution.sample(); delegate.skip(toSkip); if (delegate.hasNext()) { next = delegate.next(); } else { hasNext = false; } }
@Override public void skip(int n) { int toSkip = 0; for (int i = 0; i < n; i++) { toSkip += geometricDistribution.sample(); } delegate.skip(toSkip); if (delegate.hasNext()) { next = delegate.next(); } else { hasNext = false; } }
private void doNext() { int toSkip = geometricDistribution.sample(); delegate.skip(toSkip); if (delegate.hasNext()) { next = delegate.next(); } else { hasNext = false; } }
@Override public void skip(final int n) { int toSkip = 0; for (int i = 0; i < n; i++) { toSkip += geometricDistribution.sample(); } delegate.skip(toSkip); if (delegate.hasNext()) { next = delegate.next(); } else { hasNext = false; } }
@Override public void skip(int n) { int toSkip = 0; for (int i = 0; i < n; i++) { toSkip += geometricDistribution.sample(); } delegate.skip(toSkip); if (delegate.hasNext()) { next = delegate.next(); } else { hasNext = false; } }
@Override public void skip(int n) { int toSkip = 0; for (int i = 0; i < n; i++) { toSkip += geometricDistribution.sample(); } delegate.skip(toSkip); if (delegate.hasNext()) { next = delegate.next(); } else { hasNext = false; } }