dmultinom_rvec {rvec} | R Documentation |
Density function random generation for the multinomial distribution, modified to work with rvecs.
dmultinom_rvec(x, size = NULL, prob, log = FALSE)
rmultinom_rvec(n, size, prob, n_draw = NULL)
x |
Quantiles. Can be an rvec. |
size |
Total number of trials.
See |
prob |
Numeric non-negative vector,
giving the probability of each outcome.
Internally normalized to sum to 1.
See |
log |
Whether to return
|
n |
The length of random vector being created. Cannot be an rvec. |
n_draw |
Number of random draws in the random vector being created. Cannot be an rvec. |
Functions dmultinom_rvec()
and
rmultinom_rvec()
work like
base R functions dmultinom()
and rmultinom()
, except that
they accept rvecs as inputs. If any
input is an rvec, then the output will be too.
Function rmultinom_rvec()
also returns an
rvec if a value for n_draw
is supplied.
Like the base R functions dmultinom()
and [rmultinom(), dmultinom_rvec()
and
rmultinom_rvec()
do not recycle their arguments.
dmultinom()
If any of the arguments are rvecs,
or if a value for n_draw
is supplied,
then an rvec
Otherwise an ordinary R vector.
rmultinom()
If n
is 1, an rvec or
ordinary R vector.
If n
is greater than 1, a list
of rvecs or ordinary R vectors
x <- rvec(list(c(1, 4, 0),
c(1, 0, 0),
c(1, 0, 0),
c(1, 0, 4)))
prob <- c(1/4, 1/4, 1/4, 1/4)
dmultinom_rvec(x = x, prob = prob)
rmultinom_rvec(n = 1,
size = 100,
prob = c(0.1, 0.4, 0.2, 0.3),
n_draw = 1000)