norminvp function

Normal quantile function (high precision)

Normal quantile function (high precision)

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

norminvp(p, l, u)

Arguments

  • p: quantile at 0p10\le p\le 1
  • l: lower truncation limit
  • u: upper truncation limit

Returns

quantile value of the truncated normal distribution.

Details

Suppose we wish to simulate a random variable ZZ drawn from N(μ,σ2)N(\mu,\sigma^2) and conditional on l<Z<ul<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

Note

If you wish to simulate truncated normal variables fast, use trandn. Using norminvp is advisable only when needed, for example, in quasi-Monte Carlo or antithetic sampling, where the inverse transform method is unavoidable.

Examples

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

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

Author(s)

Zdravko I. Botev

  • Maintainer: Leo Belzile
  • License: GPL-3
  • Last published: 2024-07-08

Useful links