Learn R Programming

bayesm (version 3.0-2)

rtrun: Draw from Truncated Univariate Normal

Description

rtrun draws from a truncated univariate normal distribution

Usage

rtrun(mu, sigma, a, b)

Arguments

mu

mean

sigma

sd

a

lower bound

b

upper bound

Value

draw (possibly a vector)

Warning

This routine is a utility routine that does not check the input arguments for proper dimensions and type.

Details

Note that due to the vectorization of the rnorm,qnorm commands in R, all arguments can be vectors of equal length. This makes the inverse CDF method the most efficient to use in R.

References

For further discussion, see Bayesian Statistics and Marketing by Rossi, Allenby and McCulloch, Chapter 2. http://www.perossi.org/home/bsm-1

Examples

Run this code
##
set.seed(66)
rtrun(mu=c(rep(0,10)),sigma=c(rep(1,10)),a=c(rep(0,10)),b=c(rep(2,10)))

Run the code above in your browser using DataLab