rtnorm {tmvtnsim} | R Documentation |
Random Generation for Truncated Univariate Normal
Description
Draws from truncated univariate normal distribution within an interval.
Usage
rtnorm(mean, sd = 1, lower, upper, n = NULL)
Arguments
mean |
vector of means. The length is the number of observations. |
sd |
standard deviation. Defaults to 1. |
lower |
a scalar of lower bound for truncation, or a vector of
lower bounds with the same length as |
upper |
a scalar of upper bound for truncation, or a vector of
upper bounds with the same length as |
n |
number of random samples when |
Value
Returns a vector of random numbers following the specified truncated univariate normal distribution.
Examples
set.seed(1203)
x = rtnorm(mean=rep(1,1000), sd=2, lower=-2, upper=3)
summary(x)
# use the alternative form of input
set.seed(1203)
x = rtnorm(mean=1, sd=2, lower=-2, upper=3, n=1000)
summary(x)
[Package tmvtnsim version 0.1.3 Index]