Last data update: 2014.03.03

R: fast truncated normal generator
trandnR Documentation

fast truncated normal generator

Description

efficient state-of-the-art generator of a vector of length(l)=length(u) from the standard multivariate normal distribution, truncated over the region [l,u]; infinite values for u and l are accepted;

Usage

trandn(l,u)

Arguments

l

lower truncation limit

u

upper truncation limit

Details

If you wish to simulate a random variable Z drawn from N(μ,σ^2) conditional on l<Z<u, then first simulate X=trandn((l-mu)/sig,(u-mu)/sig) and set Z=mu+sig*X;

Value

random variable(s) drawn from the truncated normal distribution

Note

Use norminvp for the (slower) inverse transform method of simulating truncated normal variables.

Author(s)

Z. I. Botev, email: botev@unsw.edu.au and web page: http://web.maths.unsw.edu.au/~zdravkobotev/

References

Z. I. Botev (2015), The Normal Law Under Linear Restrictions: Simulation and Estimation via Minimax Tilting, submitted to JRSS(B)

See Also

See also: norminvp

Examples

d=150;l=1:d;u=l+Inf;
x=trandn(l,u)
print(x)

Results