1 #ifndef STAN_MATH_PRIM_MAT_PROB_MULTINOMIAL_LPMF_HPP 2 #define STAN_MATH_PRIM_MAT_PROB_MULTINOMIAL_LPMF_HPP 4 #include <boost/math/special_functions/gamma.hpp> 5 #include <boost/random/uniform_01.hpp> 6 #include <boost/random/variate_generator.hpp> 20 template <
bool propto,
22 typename boost::math::tools::promote_args<T_prob>::type
24 const Eigen::Matrix<T_prob, Eigen::Dynamic, 1>& theta) {
25 static const char*
function(
"multinomial_lpmf");
27 using boost::math::tools::promote_args;
30 typename promote_args<T_prob>::type lp(0.0);
34 "Size of number of trials variable", ns.size(),
35 "rows of probabilities parameter", theta.rows());
39 for (
unsigned int i = 0; i < ns.size(); ++i)
42 for (
unsigned int i = 0; i < ns.size(); ++i)
46 for (
unsigned int i = 0; i < ns.size(); ++i)
52 template <
typename T_prob>
53 typename boost::math::tools::promote_args<T_prob>::type
55 const Eigen::Matrix<T_prob, Eigen::Dynamic, 1>& theta) {
56 return multinomial_lpmf<false>(ns, theta);
fvar< T > sum(const std::vector< fvar< T > > &m)
Return the sum of the entries of the specified standard vector.
void check_simplex(const char *function, const char *name, const Eigen::Matrix< T_prob, Eigen::Dynamic, 1 > &theta)
Check if the specified vector is simplex.
fvar< T > lgamma(const fvar< T > &x)
Return the natural logarithm of the gamma function applied to the specified argument.
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.
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...
void check_nonnegative(const char *function, const char *name, const T_y &y)
Check if y is non-negative.
fvar< T > multiply_log(const fvar< T > &x1, const fvar< T > &x2)
boost::math::tools::promote_args< T_prob >::type multinomial_lpmf(const std::vector< int > &ns, const Eigen::Matrix< T_prob, Eigen::Dynamic, 1 > &theta)