SuanShu, a Java numerical and statistical library

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

Class InverseTransformSamplingTruncatedNormalRNG

• java.lang.Object
• com.numericalmethod.suanshu.stats.random.rng.univariate.normal.truncated.InverseTransformSamplingTruncatedNormalRNG
• All Implemented Interfaces:
RandomGammaGenerator, RandomNumberGenerator, Seedable

public class InverseTransformSamplingTruncatedNormalRNG
extends Object
implements RandomGammaGenerator
A random variate x defined as $x = \Phi^{-1}( \Phi(\alpha) + U\cdot(\Phi(\beta)-\Phi(\alpha)))\sigma + \mu$ with $$\Phi$$ the cumulative distribution function and $$\Phi^{-1}$$ its inverse, U a uniform random number on (0, 1), follows the distribution truncated to the range (a, b). This method is theoretically the best, however the simulation of random variables from $$\Phi$$ and $$\Phi^{-1}$$ may imply numerical errors; thus practically one has to find other implementations.
Wikipedia: Simulating
• Constructor Summary

Constructors
Constructor and Description
InverseTransformSamplingTruncatedNormalRNG(double a, double b)
Construct a rng that samples from a truncated standard Normal distribution using inverse sampling technique.
InverseTransformSamplingTruncatedNormalRNG(double mu, double sigma, double a, double b)
Construct a rng that samples from a truncated Normal distribution using inverse sampling technique.
InverseTransformSamplingTruncatedNormalRNG(double mu, double sigma, double a, double b, RandomLongGenerator uniform)
Construct a rng that samples from a truncated Normal distribution using inverse sampling technique.
• 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

• InverseTransformSamplingTruncatedNormalRNG

public InverseTransformSamplingTruncatedNormalRNG(double mu,
double sigma,
double a,
double b,
RandomLongGenerator uniform)
Construct a rng that samples from a truncated Normal distribution using inverse sampling technique.
Parameters:
mu - the mean
sigma - the standard deviation
a - the lower bound
b - the upper bound
uniform - a uniform rlg
• InverseTransformSamplingTruncatedNormalRNG

public InverseTransformSamplingTruncatedNormalRNG(double mu,
double sigma,
double a,
double b)
Construct a rng that samples from a truncated Normal distribution using inverse sampling technique.
Parameters:
mu - the mean
sigma - the standard deviation
a - the lower bound
b - the upper bound
• InverseTransformSamplingTruncatedNormalRNG

public InverseTransformSamplingTruncatedNormalRNG(double a,
double b)
Construct a rng that samples from a truncated standard Normal distribution using inverse sampling technique.
Parameters:
a - the lower bound
b - the upper bound
• Method Detail

• 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
• 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