rtuvn {tmvmixnorm} | R Documentation |
Random number generation for truncated univariate normal distribution
Description
rtuvn
simulates truncated univariate normal distribution within the interval.
Usage
rtuvn(n = 1, mean = 0, sd = 1, lower, upper)
Arguments
n |
number of random samples desired (sample size). |
mean |
mean of the underlying univariate normal distribution. |
sd |
standard deviation of the underlying univariate normal distribution. |
lower |
lower bound for truncation. |
upper |
upper bound for truncation. |
Value
rtuvn
returns a vector of random number follows truncated univariate normal distribution.
Examples
set.seed(1203)
ans <- rtuvn(n=1000, mean=1, sd=2, lower=-2, upper=3)
summary(ans)
# Check if the sample matches with CDF by KS test
ks.test(ans,"ptuvn",1,2,-2,3)
[Package tmvmixnorm version 1.1.1 Index]