rtn: random variates from truncated normal distribution

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/rtn.R

Description

Random variates from the left or right truncated normal distribution are generated. An efficient algorithm based on the inverse CDF method is used. This algorithm can be used to verify empirically the correcntess of the mean and variance computation done by the other function in this package, mvtn.

Usage

1
rtn(n, zmu = 0, zsig = 1, c = 1.96, side = c("left", "right"))

Arguments

n

number of random variables

zmu

mean parameter for normal distribution

zsig

standard deviation parameter

c

truncation point

side

either left or right

Details

The inverse cdf method is used in the case of the right truncated normal distribution. In the left truncated case, the negative of the corresponding right truncated distribution is used.

Value

the random variates, vector of length n

Author(s)

A. I. McLeod

References

For further details see the vignette.

See Also

mvtn

Examples

1
2
3
4
#Empirical validation
z<-rtn(10^4, 100, 15, c=120, side="left")
c(mean(z), var(z))
mvtn(100, 15, c=120, side="left")

mvrtn documentation built on May 2, 2019, 1:27 p.m.

Related to rtn in mvrtn...