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

◆ multinomial_logit_rng()

template<class RNG , typename T_beta , require_eigen_col_vector_t< T_beta > * = nullptr>
std::vector< int > stan::math::multinomial_logit_rng ( const T_beta &  beta,
int  N,
RNG &  rng 
)
inline

Return a draw from a Multinomial distribution given a vector of unnormalized log probabilities, a total count, and a pseudo-random number generator.

In the case of finite and -inf values this is equivalent to multinomial_rng(softmax(beta), N, rng). Entries of beta equal to -inf have zero probability; if any entries are +inf, probability is split evenly among them. These are the limits of softmax: as beta[n] -> -inf, softmax(beta)[n] -> 0, and if k entries -> +inf at the same rate, each has probability 1/k.

Template Parameters
RNGType of pseudo-random number generator.
Parameters
betaVector of unnormalized log probabilities.
NTotal count.
rngPseudo-random number generator.
Returns
Multinomial random variate.
Exceptions
std::domain_errorif beta contains NaN
std::domain_errorif beta is non-empty and every entry of beta is negative infinity
std::domain_errorif N is less than 0.

Definition at line 39 of file multinomial_logit_rng.hpp.