dmultinom_rvec {rvec}R Documentation

The Multinomial Distribution, Using Multiple Draws

Description

Density function random generation for the multinomial distribution, modified to work with rvecs.

Usage

dmultinom_rvec(x, size = NULL, prob, log = FALSE)

rmultinom_rvec(n, size, prob, n_draw = NULL)

Arguments

x

Quantiles. Can be an rvec.

size

Total number of trials. See stats::dmultinom(). Can be an rvec.

prob

Numeric non-negative vector, giving the probability of each outcome. Internally normalized to sum to 1. See stats::dmultinom(). Can be an rvec.

log

Whether to return log(p) rather than p. Default is FALSE. Cannot be an rvec.

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.

Details

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.

Value

See Also

Examples

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)

[Package rvec version 0.0.6 Index]