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 |
|
n |
Number of generated observations. |
lower |
|
upper |
|
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 maximumb
of the uniform distributionU_{[a,b]}
it holds thata = l - 0.05 (u - l)
andb= 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})
forx > 0
andf(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))