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: =lower
and =
upper
;
is the cumulative distribution function of the standard normal distribution and
its inverse, which is the quantile function of the standard normal
distribution.
distribution="norm":
The formulae for
and
, viz. the mean and standard deviation, respectively, of the normal distribution are
and
.
distribution="unif":
For the minimum
and maximum
of the uniform distribution
it holds that
and
.
distribution="lnorm":
The density of the log normal distribution is
for
and
otherwise. Its parameters are determined by the confidence interval via
and
. 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))