File: rtrun.Rd

package info (click to toggle)
r-cran-bayesm 3.1-5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,204 kB
  • sloc: cpp: 3,115; ansic: 89; makefile: 7; sh: 4
file content (42 lines) | stat: -rwxr-xr-x 1,412 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
\name{rtrun}
\alias{rtrun}
\concept{truncated normal}
\concept{simulation}

\title{Draw from Truncated Univariate Normal}

\description{
\code{rtrun} draws from a truncated univariate normal distribution.
}

\usage{rtrun(mu, sigma, a, b)}

\arguments{
  \item{mu}{ mean }
  \item{sigma}{ standard deviation }
  \item{a}{ lower bound }
  \item{b}{ upper bound }
}

\details{
Note that due to the vectorization of the \code{rnorm} and \code{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.
}

\value{Draw (possibly a vector)}

\section{Warning}{
This routine is a utility routine that does \strong{not} check the input arguments for proper dimensions and type.

**Note also that \code{rtrun} is currently affected by the numerical accuracy of the inverse CDF function when trunctation points are far out in the tails of the distribution, where \dQuote{far out} means \eqn{|a - \mu| / \sigma > 6} and/or \eqn{|b - \mu| / \sigma > 6}. A fix will be implemented in a future version of \code{bayesm}.
}

\author{Peter Rossi, Anderson School, UCLA, \email{perossichi@gmail.com}.}

\references{For further discussion, see Chapter 2, \emph{Bayesian Statistics and Marketing} by Rossi, Allenby, and McCulloch.}

\examples{
set.seed(66)
rtrun(mu=c(rep(0,10)), sigma=c(rep(1,10)), a=c(rep(0,10)), b=c(rep(2,10)))
}

\keyword{distribution}