1#ifndef STAN_MATH_PRIM_PROB_MULTINOMIAL_LPMF_HPP
2#define STAN_MATH_PRIM_PROB_MULTINOMIAL_LPMF_HPP
15template <
bool propto,
typename T_prob,
16 require_eigen_col_vector_t<T_prob>* =
nullptr>
18 const T_prob& theta) {
19 static constexpr const char* function =
"multinomial_lpmf";
21 "rows of probabilities parameter", theta.rows());
23 const auto& theta_ref =
to_ref(theta);
24 check_simplex(function,
"Probabilities parameter", theta_ref);
37 for (
unsigned int i = 0; i < ns.size(); ++i) {
44template <
typename T_prob>
46 const T_prob& theta) {
47 return multinomial_lpmf<false>(ns, theta);
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
fvar< T > multiply_log(const fvar< T > &x1, const fvar< T > &x2)
void check_nonnegative(const char *function, const char *name, const T_y &y)
Check if y is non-negative.
return_type_t< T_prob > multinomial_lpmf(const std::vector< int > &ns, const T_prob &theta)
void check_simplex(const char *function, const char *name, const T &theta)
Throw an exception if the specified vector is not a simplex.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
fvar< T > lgamma(const fvar< T > &x)
Return the natural logarithm of the gamma function applied to the specified argument.
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
void check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
Check if the provided sizes match.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...