vexp {simEd} | R Documentation |
Variate Generation for Exponential Distribution
Description
Variate Generation for Exponential Distribution
Usage
vexp(n, rate = 1, stream = NULL, antithetic = FALSE, asList = FALSE)
Arguments
n |
number of observations |
rate |
Rate of distribution (default 1) |
stream |
if |
antithetic |
if |
asList |
if |
Details
Generates random variates from the exponential distribution.
Exponential variates are generated by inverting uniform(0,1) variates
produced either by stats::runif
(if stream
is
NULL
) or by rstream::rstream.sample
(if stream
is not NULL
).
In either case, stats::qexp
is used to
invert the uniform(0,1) variate(s).
In this way, using vexp
provides a monotone and synchronized
binomial variate generator, although not particularly fast.
The stream indicated must be an integer between 1 and 25 inclusive.
The exponential distribution with rate \eqn{\lambda} has density \deqn{f(x) = \lambda e^{-\lambda x}}{ f(x) = \lambda e^(-\lambda x)} for \eqn{x \geq 0}.
Value
If asList
is FALSE (default), return a vector of random variates.
Otherwise, return a list with components suitable for visualizing inversion, specifically:
u |
A vector of generated U(0,1) variates |
x |
A vector of exponential random variates |
quantile |
Parameterized quantile function |
text |
Parameterized title of distribution |
Author(s)
Barry Lawson (blawson@bates.edu),
Larry Leemis (leemis@math.wm.edu),
Vadim Kudlay (vkudlay@nvidia.com)
See Also
rstream
, set.seed
,
stats::runif
Examples
set.seed(8675309)
# NOTE: following inverts rstream::rstream.sample using stats::qexp
vexp(3, rate = 2)
set.seed(8675309)
# NOTE: following inverts rstream::rstream.sample using stats::qexp
vexp(3, 2, stream = 1)
vexp(3, 2, stream = 2)
set.seed(8675309)
# NOTE: following inverts rstream::rstream.sample using stats::qexp
vexp(1, 2, stream = 1)
vexp(1, 2, stream = 2)
vexp(1, 2, stream = 1)
vexp(1, 2, stream = 2)
vexp(1, 2, stream = 1)
vexp(1, 2, stream = 2)
set.seed(8675309)
variates <- vexp(100, 2, stream = 1)
set.seed(8675309)
variates <- vexp(100, 2, stream = 1, antithetic = TRUE)
set.seed(8675309)
# NOTE: Default functions for M/M/1 ssq(), ignoring fixed n
interarrivals <- vexp(1000, rate = 1, stream = 1)
services <- vexp(1000, rate = 10/9, stream = 2)