Random generation for the truncated normal distribution. The mean and standard deviation of the original normal distribution are mean and sd. Truncation limits are given by a, b, type of truncation is given by trunc.
rTNorm(n, mean=0, sd=1, a, b, trunc)
Arguments
mean: mean (if common for all observations) or a vector of length n of means.
sd: standard deviation (if common for all observations) or a vector of length n of standard deviations.
Note that mean and sd
must have the same length, either 1 or n.
a: truncation limit 1 (if common for all observations) or a vector of length n of truncation limits 1.
b: truncation limit 2 (if common for all observations) or a vector of length n of truncation limits 2.
trunc: type of truncation (if common for all observations) or a vector of length n of types of truncation
trunc=0: normal distribution is truncated on the interval (a,Infty). Value of b is ignored.
trunc=1: degenerated normal distribution, all values are with probability 1 equal to a, b is ignored.
trunc=2: normal distribution is truncated on the interval (−Infty,a). Value of b is ignored.
trunc=3: normal distribution is truncated on the interval (a,b).
trunc=4: there is no truncation, values of a
and $b$ are ignored.
If trunc is not given, it is assumed that it is equal to 4. Note that a, b and trunc
must have the same length, either 1 or n with exception that b does not have to be supplied if trunc is 0, 1, 2 or 4.
n: number of observations to be sampled.
Returns
A numeric vector with sampled values.
References
Geweke, J. (1991). Efficient simulation from the multivariate normal and Student-t distributions subject to linear constraints and the evaluation of constraint probabilities. Computer Sciences and Statistics, 23 , 571--578.