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

◆ categorical_logit_lpmf() [2/3]

template<bool propto, typename T_prob , require_col_vector_t< T_prob > * = nullptr>
return_type_t< T_prob > stan::math::categorical_logit_lpmf ( const std::vector< int > &  ns,
const T_prob &  beta 
)
inline

Categorical log PMF in log-odds parametrization, summed over an array of outcomes.

Categorical(ns | softmax(beta))

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.

If ns is empty the log probability is 0; in that case beta may also be empty.

Parameters
nsArray of outcomes, each in 1:size(beta)
betaVector of log odds (unnormalized log probabilities)
Returns
sum of the log probabilities of the outcomes
Exceptions
std::domain_errorif any element of ns is not in 1:size(beta)
std::domain_errorif beta contains NaN
std::domain_errorif beta is non-empty and every entry of beta is negative infinity
std::domain_errorif beta is an autodiff (var) type and contains any non-finite value

Definition at line 96 of file categorical_logit_lpmf.hpp.