Class InverseTransformSamplingTruncatedNormalRNG
java.lang.Object
dev.nm.stat.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.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionInverseTransformSamplingTruncatedNormalRNG
(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
Modifier and TypeMethodDescriptiondouble
Get the next randomdouble
.void
seed
(long... seeds) Seed the random number/vector/scenario generator to produce repeatable experiments.
-
Constructor Details
-
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 meansigma
- the standard deviationa
- the lower boundb
- the upper bounduniform
- 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 meansigma
- the standard deviationa
- the lower boundb
- 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 boundb
- the upper bound
-
-
Method Details
-
nextDouble
public double nextDouble()Description copied from interface:RandomNumberGenerator
Get the next randomdouble
.- Specified by:
nextDouble
in interfaceRandomNumberGenerator
- 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.
-