View source: R/distributions.R
| dmultinom_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; otherwise a list
of rvecs or ordinary R vectors
Unlike base rmultinom(), rmultinom_rvec()
always returns doubles.
dmultinom(), rmultinom() Base R equivalents
distributions All base R distributions
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.