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
-
| RNG | Type of pseudo-random number generator. |
- Parameters
-
| beta | Vector of unnormalized log probabilities. |
| N | Total count. |
| rng | Pseudo-random number generator. |
- Returns
- Multinomial random variate.
- Exceptions
-
| std::domain_error | if beta contains NaN |
| std::domain_error | if beta is non-empty and every entry of beta is negative infinity |
| std::domain_error | if N is less than 0. |
Definition at line 39 of file multinomial_logit_rng.hpp.