Learn R Programming

metaBMA (version 0.3.9)

dtruncnorm: Truncated Normal Distribution

Description

Normal distribution truncated to the interval [a,b]

Usage

dtruncnorm(x, a = -Inf, b = Inf, mean = 0, sd = 1, log = FALSE)

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

Arguments

x

vector of quantiles

a

lower bound

b

upper bound

mean

vector of means

sd

vector of standard deviations

log

if TRUE, probabilities are given as log(p)

n

number of samples

Examples

Run this code
# NOT RUN {
samples <- rtruncnorm(1e5, -.5, 3, 1, 1)
hist(samples, 200, freq = FALSE)
curve(dtruncnorm(x, -.5, 3, 1, 1), -2,4,
      col = 2, lwd = 2, add = TRUE, n = 301)
# }

Run the code above in your browser using DataLab