ulnormal: adapted draws of a log-normal distribution

Description Usage Arguments Details Value Examples

Description

This function slightly generalizes the basic rlnorm function, allowing a different support that [0,+Inf[ with support and 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.
Notice that support[2] is not a bound, only its sign is used to know if the support is [support[1],+Inf[ when plus or ]-Inf,support[1] when minus.

Usage

1
ulnormal(mu, coefvar, support=c(0, +1), trunc=c(0, Inf))

Arguments

mu

numeric vector of the expectation of the normal (i.e. in the log scale).

coefvar

numeric vector of the coefficient of variation (also in the log scale). Cannot be negative.

support

Defines the support of the log-normal distribution. This is either [support[1],+Inf[ when support[2] >= 0 or ]-Inf,support[1] when support[2] < 0. Of course, this is not in the log scale. The support semi-interval is common for all draws.

trunc

The two limits (not in the log scale) to which the distribution is truncated. It will be restricted to its intersection with the support. The truncation interval is common for all draws.

Details

To comply with /prr/ point of view, the second parameter of the log-normal distribution is given through the variation coefficient.
In fact, after making the appropriate transformation, this function calls the unormal function. To make the code safer, also the check of the consistency of the parameters is made by unormal not by ulnormal.
The remark made for unormal applies to this function too (since it is called). This can generate missing values (NA) for too small mu components.

Value

A vector of the drawn values, possibly containing NA.

Examples

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

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

Related to ulnormal in prr...