Learn R Programming

bayess (version 1.6)

truncnorm: Random simulator for the truncated normal distribution

Description

This is a plain random generator for a normal variate \(\mathcal{N}(\mu,\tau^2)\) truncated to \((a,b)\), using the inverse cdf qnorm. It may thus be imprecise for extreme values of the bounds.

Usage

truncnorm(n, mu, tau2, a, b)

Value

a sample of real numbers over \((a,b)\) with size n

Arguments

n

number of simulated variates

mu

mean of the original normal

tau2

variance of the original normal

a

lower bound

b

upper bound

See Also

reconstruct

Examples

Run this code
x=truncnorm(10^3,1,2,3,4)
hist(x,nclass=123,col="wheat",prob=TRUE)

Run the code above in your browser using DataLab