Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ dirichlet_multinomial_rng()

template<class RNG >
std::vector< int > stan::math::dirichlet_multinomial_rng ( const Eigen::Matrix< double, Eigen::Dynamic, 1 > &  alpha,
int  N,
RNG &  rng 
)
inline

Return a draw from a Dirichlet-Multinomial distribution with specified parameters \(\alpha\) and \(N\) and pseudo-random number generator rng.

The Dirichlet-Multinomial distribution is a continuous mixture of Multinomial distirbutions, where the mixing distribution is the Dirichlet distribution. This fact is used for generating DirMult random draws. First, we sample a probability vector \(\theta \sim \mbox{Dirichlet}(\alpha)\). Then, we sample a \(n \sim \mbox{Multinomial}(\theta, N)\), and return \(n\).

Template Parameters
RNGtype of pseudo-random number generator
Parameters
alphaPrior sample sizes (or intensity vector).
NNumber of trials.
rngPseudo-random number generator.
Returns
A non-negative integer vector n with sum(n) = N.
Exceptions
std::domain_errorif any element of alpha is less than or equal to 0, or infinite.
std::domain_erroris N is less than 0.

Definition at line 37 of file dirichlet_multinomial_rng.hpp.