These functions generate random numbers for parametric distributions, parameters of which are determined by given quantiles or for distributions purely defined empirically.
random(rho, n, method, relativeTolerance, ...)# S3 method for default
random(
rho = list(distribution = "norm", probabilities = c(0.05, 0.95), quantiles =
c(-qnorm(0.95), qnorm(0.95))),
n,
method = "fit",
relativeTolerance = 0.05,
...
)
# S3 method for vector
random(rho = runif(n = n), n, method = NULL, relativeTolerance = NULL, ...)
# S3 method for data.frame
random(
rho = data.frame(uniform = runif(n = n)),
n,
method = NULL,
relativeTolerance = NULL,
...
)
Distribution to be randomly sampled.
integer
: Number of observations to be generated
character
: Particular method to be used for random number generation.
numeric
: the relative tolerance level of deviation of the
generated confidence interval from the specified interval. If this deviation is greater than
relativeTolerance
a warning is given.
Optional arguments to be passed to the particular random number generating function.
random(default)
: Quantiles based univariate random number generation.
rho
rho list
: Distribution to be randomly sampled. The list elements are
$distribution
, $probabilities
and $quantiles
. For details cf. below.
method
character
: Particular method to be used for random number
generation. Currently only method rdistq_fit{fit}
is implemented which is the
default.
relativeTolerance
numeric
: the relative tolerance level of deviation of the generated confidence
interval from the specified interval. If this deviation is greater than
relativeTolerance
a warning is given.
...
Optional arguments to be passed to the particular random number
generating function, i.e. rdistq_fit
.
random(vector)
: Univariate random number generation by drawing from a given
empirical sample.
rho
vector
: Univariate empirical sample to be sampled from.
method
for this class no impact
relativeTolerance
for this class no impact
...
for this class no impact
random(data.frame)
: Multivariate random number generation by drawing from a given empirical sample.
rho
data.frame
: Multivariate empirical sample to be sampled from.
method
for this class no impact
relativeTolerance
for this class no impact
...
for this class no impact
x<-random(n=10000)
hist(x,breaks=100)
mean(x)
sd(x)
rho<-list(distribution="norm",
probabilities=c(0.05,0.4,0.8),
quantiles=c(-4, 20, 100))
x<-random(rho=rho, n=10000, tolConv=0.01)
hist(x,breaks=100)
quantile(x,p=rho[["probabilities"]])
Run the code above in your browser using DataLab