powered by
rtnorm(num=1, mu=0.0, sig=1.0, left=-Inf, right=Inf)
This routine follows Robert (1995) to sample a truncated normal.
For mu, sig, left, and right you may send sequences of parameters in addition to scalars.
Christian Robert. Simulation of truncated normal random variables. Statistics and Computing. 1995. Vol 5, p. 121-125.
samp = rtnorm(100, c(-1.0, 1.0), c(0.5, 0.2), -4, 4);
Run the code above in your browser using DataLab