Learn R Programming

bayesm (version 2.0-9)

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)

concept

  • truncated normal
  • simulation

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://faculty.chicagogsb.edu/peter.rossi/research/bsm.html

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