rdist90ci_exact {decisionSupport}R Documentation

90%-confidence interval based univariate random number generation (by exact parameter calculation).

Description

This function generates random numbers for a set of univariate parametric distributions from given 90% confidence interval. Internally, this is achieved by exact, i.e. analytic, calculation of the parameters for the individual distribution from the given 90% confidence interval.

Usage

rdist90ci_exact(distribution, n, lower, upper)

Arguments

distribution

character; A character string that defines the univariate distribution to be randomly sampled. For possible options cf. section Details.

n

Number of generated observations.

lower

numeric; lower bound of the 90% confidence interval.

upper

numeric; upper bound of the 90% confidence interval.

Details

The following table shows the available distributions and their identification (option: distribution) as a character string:

distribution Distribution Name Requirements
"const" Deterministic case lower == upper
"norm" Normal lower < upper
"lnorm" Log Normal 0 < lower < upper
"unif" Uniform lower < upper

Parameter formulae

We use the notation: l=lower and u=upper; \Phi is the cumulative distribution function of the standard normal distribution and \Phi^{-1} its inverse, which is the quantile function of the standard normal distribution.

distribution="norm":

The formulae for \mu and \sigma, viz. the mean and standard deviation, respectively, of the normal distribution are \mu=\frac{l+u}{2} and \sigma=\frac{\mu - l}{\Phi^{-1}(0.95)}.

distribution="unif":

For the minimum a and maximum b of the uniform distribution U_{[a,b]} it holds that a = l - 0.05 (u - l) and b= u + 0.05 (u - l) .

distribution="lnorm":

The density of the log normal distribution is f(x) = \frac{1}{ \sqrt{2 \pi} \sigma x } \exp( - \frac{( \ln(x) - \mu )^2 % }{ 2 \sigma^2}) for x > 0 and f(x) = 0 otherwise. Its parameters are determined by the confidence interval via \mu = \frac{\ln(l) + \ln(u)}{2} and \sigma = \frac{1}{\Phi^{-1}(0.95)} ( \mu - \ln(l) ) . Note the correspondence to the formula for the normal distribution.

Value

A numeric vector of length n with the sampled values according to the chosen distribution.

In case of distribution="const", viz. the deterministic case, the function returns: rep(lower, n).

Examples

# Generate uniformly distributed random numbers:
lower=3
upper=6
hist(r<-rdist90ci_exact(distribution="unif", n=10000, lower=lower, upper=upper),breaks=100)
print(quantile(x=r, probs=c(0.05,0.95)))
print(summary(r))

# Generate log normal distributed random numbers:
hist(r<-rdist90ci_exact(distribution="lnorm", n=10000, lower=lower, upper=upper),breaks=100)
print(quantile(x=r, probs=c(0.05,0.95)))
print(summary(r))

[Package decisionSupport version 1.114 Index]