SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.random.distribution
Class InverseTransformSampling

java.lang.Object
  extended by com.numericalmethod.suanshu.stats.random.distribution.InverseTransformSampling
All Implemented Interfaces:
RandomNumberGenerator
Direct Known Subclasses:
Exponential, Rayleigh, Weibull

public class InverseTransformSampling
extends java.lang.Object
implements RandomNumberGenerator

This class creates a random variable from a UnivariateDistribution instance.

To generate a random variable X with a cumulative distribution function F(x) for all x, we first sample u from the uniform distribution Uniform[0,1]. Then, x = F-1(u) = Q(u).

This method requires that F has a continuous density function, hence, strictly increasing and its inverse well defined.

See Also:

Field Summary
 UnivariateDistribution distribution
          the distribution to generate random samples from
 
Constructor Summary
InverseTransformSampling(UnivariateDistribution distribution)
          Construct a random number generator by sampling from a distribution.
InverseTransformSampling(UnivariateDistribution distribution, RandomNumberGenerator uniform)
          Construct a random number generator by sampling from a distribution.
 
Method Summary
 double nextDouble()
          Get the next random double.
 void seed(long... seeds)
          Seed the random number generator to produce repeatable sequences.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

distribution

public final UnivariateDistribution distribution
the distribution to generate random samples from

Constructor Detail

InverseTransformSampling

public InverseTransformSampling(UnivariateDistribution distribution,
                                RandomNumberGenerator uniform)
Construct a random number generator by sampling from a distribution.

Parameters:
distribution - the distribution to sample from
uniform - the uniform random number generator that generates u between 0 and 1

InverseTransformSampling

public InverseTransformSampling(UnivariateDistribution distribution)
Construct a random number generator by sampling from a distribution. The uniform random number generator used is the library default, namely, RNG.

Parameters:
distribution - the distribution to sample from
Method Detail

seed

public void seed(long... seeds)
Description copied from interface: RandomNumberGenerator
Seed the random number generator to produce repeatable sequences.

Specified by:
seed in interface RandomNumberGenerator
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

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.