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

◆ categorical_logit_rng()

template<class RNG >
int stan::math::categorical_logit_rng ( const Eigen::VectorXd &  beta,
RNG &  rng 
)
inline

Return a draw from a Categorical distribution given a vector of unnormalized log probabilities and a pseudo-random number generator.

In the case of finite and -inf values this is a convenience wrapper around categorical_rng(softmax(beta), 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.
rngPseudo-random number generator.
Returns
Categorical random variate
Exceptions
std::domain_errorif beta contains NaN
std::domain_errorif every entry of beta is negative infinity

Definition at line 36 of file categorical_logit_rng.hpp.