Variate Generation for Logistic Distribution
Variate Generation for Logistic Distribution
vlogis( n, location = 0, scale = 1, stream = NULL, antithetic = FALSE, asList = FALSE )
n |
number of observations |
location |
Location parameter |
scale |
Scale parameter (default 1) |
stream |
if |
antithetic |
if |
asList |
if |
Generates random variates from the logistic distribution.
Logistic 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::qlogis
is used to
invert the uniform(0,1) variate(s).
In this way, using vlogis
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 logistic distribution with location
= μ and
scale
= σ has distribution function
F(x) = 1 / (1 + exp(-(x-μ)/σ))
and density
f(x) = 1/σ exp((x-μ)/σ) (1 + exp((x-μ)/σ))^-2
It is a long-tailed distribution with mean μ and variance π^2 /3 σ^2.
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 logistic random variates |
quantile |
Parameterized quantile function |
text |
Parameterized title of distribution |
Barry Lawson (blawson@richmond.edu),
Larry Leemis (leemis@math.wm.edu),
Vadim Kudlay (vadim.kudlay@richmond.edu)
set.seed(8675309) # NOTE: following inverts rstream::rstream.sample using stats::qlogis vlogis(3, location = 5, scale = 0.5) set.seed(8675309) # NOTE: following inverts rstream::rstream.sample using stats::qlogis vlogis(3, 5, 1.5, stream = 1) vlogis(3, 5, 1.5, stream = 2) set.seed(8675309) # NOTE: following inverts rstream::rstream.sample using stats::qlogis vlogis(1, 5, 1.5, stream = 1) vlogis(1, 5, 1.5, stream = 2) vlogis(1, 5, 1.5, stream = 1) vlogis(1, 5, 1.5, stream = 2) vlogis(1, 5, 1.5, stream = 1) vlogis(1, 5, 1.5, stream = 2) set.seed(8675309) variates <- vlogis(1000, 5, 1.5, stream = 1) set.seed(8675309) variates <- vlogis(1000, 5, 1.5, stream = 1, antithetic = TRUE)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.