# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.random.rng.univariate

## Class BinomialRNG

• java.lang.Object
• com.numericalmethod.suanshu.stats.random.rng.univariate.BinomialRNG
• All Implemented Interfaces:
RandomNumberGenerator, Seedable

public class BinomialRNG
extends Object
implements RandomNumberGenerator
This random number generator samples from the binomial distribution.

The R equivalent class are dbinom, pbinom, qbinom, rbinom.

Wikipedia: Binomial distribution
• ### Constructor Summary

Constructors
Constructor and Description
BinomialRNG(int n, double p)
Construct a random number generator to sample from the binomial distribution.
BinomialRNG(int n, double p, RandomLongGenerator uniform)
Construct a random number generator to sample from the binomial distribution.
• ### Method Summary

All Methods
Modifier and Type Method and Description
double nextDouble()
Get the next random double.
void seed(long... seeds)
Seed the random number/vector/scenario generator to produce repeatable experiments.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### BinomialRNG

public BinomialRNG(int n,
double p,
RandomLongGenerator uniform)
Construct a random number generator to sample from the binomial distribution.
Parameters:
n - the number of trials, a natural number
p - the success probability in each trial, [0, 1]
uniform - a uniform random number generator
• #### BinomialRNG

public BinomialRNG(int n,
double p)
Construct a random number generator to sample from the binomial distribution.
Parameters:
n - the number of trials, a natural number
p - the success probability in each trial, [0, 1]
• ### Method Detail

• #### seed

public void seed(long... seeds)
Description copied from interface: Seedable
Seed the random number/vector/scenario generator to produce repeatable experiments.
Specified by:
seed in interface Seedable
Parameters:
seeds - the seeds
• #### nextDouble

public double nextDouble()
Description copied from interface: RandomNumberGenerator
Get the next random double.
Specified by:
nextDouble in interface RandomNumberGenerator
Returns:
the next random number