pdf, cdf, inverse cdf, and random deviates of the truncated normal distribution.

rtnorm(n, mean = 0, sd = 1, a = -Inf, b = Inf)

dtnorm(x, mean = 0, sd = 1, a = -Inf, b = Inf)

ptnorm(q, mean = 0, sd = 1, a = -Inf, b = Inf)

qtnorm(p, mean = 0, sd = 1, a = -Inf, b = Inf)

Arguments

n

number of observations. If length(n) > 1, the length is taken to be the number required.

mean

vector of means.

sd

vector of standard deviations.

a

vector of lower truncation limits

b

vector of upper truncation limits

x, q

vector of quantiles.

p

vector of probabilities.

Value

dtnorm gives the density, ptnorm gives the distribution function, qtnorm gives the quantile function, and rtnorm generates random deviates.

Examples

rtnorm(5, 1, 2, 0.5, 3.0)
#> [1] 2.0528324 0.7214895 1.0087468 1.9783017 0.7178606
dtnorm(seq(0, 4, by=0.5), 1, 2, 0.5, 3.0)
#> [1] 0.0000000 0.4393446 0.4532909 0.4393446 0.4000278 0.3421619 0.2749348 #> [8] 0.0000000 0.0000000
ptnorm(seq(0, 4, by=0.5), 1, 2, 0.5, 3.0)
#> [1] 0.0000000 0.0000000 0.2243065 0.4486130 0.6593980 0.8455359 1.0000000 #> [8] 1.0000000 1.0000000
qtnorm(seq(0, 1, by=0.1), 1, 2, 0.5, 3.0)
#> [1] 0.5000000 0.7249038 0.9463712 1.1671810 1.3900540 1.6178947 1.8540768 #> [8] 2.1028535 2.3700412 2.6643126 3.0000000