unormal: adapted draws of a normal distribution

Description Usage Arguments Details Value Examples

Description

This function slightly generalizes the basic rnorm function, allowing truncation with trunc.
The number of returned draws is max(length(mu),length(coefvar)). When both lengths are not equal, the smaller one must be equal to one, if not an error is issued.
NA value are possible in mu and coefvar, then missing values are returned for the considered draws.

Usage

1
unormal(mu, coefvar, trunc=c(-Inf, Inf))

Arguments

mu

numeric vector of the expectation of the normal.

coefvar

numeric vector of the coefficient of variation. Cannot be negative.

trunc

The two limits to which distribution is truncated. The truncation interval is common for all draws.

Details

To comply with /prr/ point of view, the second parameter of the normal distribution is given through the variation coefficient. The relation with more standard sigma is given by
sigma = (coefvar/100)*abs(mu) and
coefvar = (100*sigma) / abs(mu). Notice that as the standard deviation is given through the variation coefficient, expectation values too close to zero can be problematic. This is why, such values are discarded and replaced by NA. A local constant is used for the test.

Value

A vector of the drawn values, possibly containing NA.

Examples

1
2
3
4
 prr3k("RESET"); # For R checking compliance
 unormal(rep(10, 20), 2);
 unormal(c(rep(10, 19), NA), 2);
 unormal(c(rep(10, 19), NA), 2, trunc=c(8, 12));

prr documentation built on May 2, 2019, 6:35 p.m.

Related to unormal in prr...