Learn R Programming

TruncatedNormal (version 2.3)

norminvp: Normal quantile function (high precision)

Description

Computes with tail-precision the quantile function of the standard normal distribution at \(0\le p\le 1\), and truncated to the interval \([l,u]\). Infinite values for vectors \(l\) and \(u\) are accepted.

Usage

norminvp(p, l, u)

Value

quantile value of the truncated normal distribution.

Arguments

p

quantile at \(0\le p\le 1\)

l

lower truncation limit

u

upper truncation limit

Author

Zdravko I. Botev

Details

Suppose we wish to simulate a random variable \(Z\) drawn from \(N(\mu,\sigma^2)\) and conditional on \(l<Z<u\) using the inverse transform method. To achieve this, first compute X=norminvp(runif(1),(l-mu)/sig,(u-mu)/sig) and then set Z=mu+sig*X

References

Z. I. Botev (2017), The Normal Law Under Linear Restrictions: Simulation and Estimation via Minimax Tilting, Journal of the Royal Statistical Society, Series B, 79 (1), pp. 1--24.

See Also

trandn

Examples

Run this code
 d <- 150 # simulate via inverse transform method
 norminvp(runif(d),l = 1:d, u = rep(Inf, d))

Run the code above in your browser using DataLab