Variate Generation for Student T Distribution
Variate Generation for Student T Distribution
vt(n, df, ncp = 0, stream = NULL, antithetic = FALSE, asList = FALSE)
n |
number of observations |
df |
Degrees of freedom > 0 |
ncp |
Non-centrality parameter delta (default NULL) |
stream |
if |
antithetic |
if |
asList |
if |
Generates random variates from the Student t distribution.
Student T 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::qt
is used to
invert the uniform(0,1) variate(s).
In this way, using vt
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 t-distribution with df
= v degrees of freedom has density
f(x) = Γ((v+1)/2) / (√(v π) Γ(v/2)) (1 + x^2/v)^-((v+1)/2)
for all real x. It has mean 0 (for v > 1) and variance v/(v-2) (for v > 2).
The general non-central t with parameters (v, δ) =
(df, ncp)
is defined as the distribution of
T(df, Del) := (U + Del) / √(V/df)
where U and V are
independent random variables, U ~ N(0,1)
and V ~ χ^2(df).
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 Student t 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::qt vt(3, df = 3, ncp = 2) set.seed(8675309) # NOTE: following inverts rstream::rstream.sample using stats::qt vt(3, 2, stream = 1) vt(3, 2, stream = 2) set.seed(8675309) # NOTE: following inverts rstream::rstream.sample using stats::qt vt(1, 2, stream = 1) vt(1, 2, stream = 2) vt(1, 2, stream = 1) vt(1, 2, stream = 2) vt(1, 2, stream = 1) vt(1, 2, stream = 2) set.seed(8675309) variates <- vt(1000, 2, stream = 1) set.seed(8675309) variates <- vt(1000, 2, stream = 1, antithetic = TRUE)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.