Variate Generation for Normal Distribution
Variate Generation for Normal Distribution
vnorm(n, mean = 0, sd = 1, stream = NULL, antithetic = FALSE, asList = FALSE)
n |
number of observations |
mean |
Mean of distribution (default 0) |
sd |
Standard deviation of distribution (default 1) |
stream |
if |
antithetic |
if |
asList |
if |
Generates random variates from the normal distribution.
Normal 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::qnorm
is used to
invert the uniform(0,1) variate(s).
In this way, using vnorm
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 normal distribution has density
f(x) = 1/(√(2π)σ) e^(-(x - μ)^2/(2 σ^2))
for -∞ < x < ∞ and σ > 0, where μ is the mean of the distribution and σ the standard deviation.
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 normal 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::qnorm vnorm(3, mean = 2, sd = 1) set.seed(8675309) # NOTE: following inverts rstream::rstream.sample using stats::qnorm vnorm(3, 10, 2, stream = 1) vnorm(3, 10, 2, stream = 2) set.seed(8675309) # NOTE: following inverts rstream::rstream.sample using stats::qnorm vnorm(1, 10, 2, stream = 1) vnorm(1, 10, 2, stream = 2) vnorm(1, 10, 2, stream = 1) vnorm(1, 10, 2, stream = 2) vnorm(1, 10, 2, stream = 1) vnorm(1, 10, 2, stream = 2) set.seed(8675309) variates <- vnorm(1000, 10, 2, stream = 1) set.seed(8675309) variates <- vnorm(1000, 10, 2, stream = 1, antithetic = TRUE)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.