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
-
| RNG | Type of pseudo-random number generator. |
- Parameters
-
| beta | Vector of unnormalized log probabilities. |
| rng | Pseudo-random number generator. |
- Returns
- Categorical random variate
- Exceptions
-
| std::domain_error | if beta contains NaN |
| std::domain_error | if every entry of beta is negative infinity |
Definition at line 36 of file categorical_logit_rng.hpp.