# SuanShu, a Java numerical and statistical library

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

## Class InverseTransformSampling

• java.lang.Object
• com.numericalmethod.suanshu.stats.random.rng.univariate.InverseTransformSampling
• All Implemented Interfaces:
RandomNumberGenerator, Seedable
Direct Known Subclasses:
InverseTransformSamplingExpRNG, InverseTransformSamplingGammaRNG, RayleighRNG, WeibullRNG

public class InverseTransformSampling
extends Object
implements RandomNumberGenerator
Inverse transform sampling (also known as inversion sampling, the inverse probability integral transform, the inverse transformation method, Smirnov transform, golden rule, etc.) is a basic method for pseudo-random number sampling, i.e. for generating sample numbers at random from any probability distribution given its cumulative distribution function. This basic idea is this: to generate a random variable X with a cumulative distribution function F(x) for all x, we first sample u from the uniform distribution. Then, x = F-1(u) = Q(u). This method requires that F(x) has a continuous density function, hence, strictly increasing and its inverse well defined.
• ### Constructor Summary

Constructors
Constructor and Description
InverseTransformSampling(ProbabilityDistribution distribution)
Construct a random number generator to sample from a distribution.
InverseTransformSampling(ProbabilityDistribution distribution, RandomLongGenerator uniform)
Construct a random number generator to sample from a 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

• #### InverseTransformSampling

public InverseTransformSampling(ProbabilityDistribution distribution,
RandomLongGenerator uniform)
Construct a random number generator to sample from a distribution.
Parameters:
distribution - the distribution to sample from
uniform - a uniform random number generator
• #### InverseTransformSampling

public InverseTransformSampling(ProbabilityDistribution distribution)
Construct a random number generator to sample from a distribution.
Parameters:
distribution - the distribution to sample from
• ### 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