Generates random samples from a normal distribution truncated between specified lower and upper bounds.
Details
The function uses inverse transform sampling by first computing the cumulative probabilities corresponding to the lower and upper bounds, then sampling uniformly from this range and transforming back via the normal quantile function.
Examples
set.seed(123)
rtruncnorm(n = 5, mean = 0, sd = 1, low = -1, high = 1)
#> [1] -0.3719060 0.5152845 -0.1563984 0.7110777 0.8441328
