1 #ifndef STAN_MATH_PRIM_MAT_PROB_MULTINOMIAL_LOG_HPP
2 #define STAN_MATH_PRIM_MAT_PROB_MULTINOMIAL_LOG_HPP
4 #include <boost/math/special_functions/gamma.hpp>
5 #include <boost/random/uniform_01.hpp>
6 #include <boost/random/variate_generator.hpp>
21 template <
bool propto,
23 typename boost::math::tools::promote_args<T_prob>::type
25 const Eigen::Matrix<T_prob, Eigen::Dynamic, 1>& theta) {
26 static const char*
function(
"stan::math::multinomial_log");
31 using boost::math::tools::promote_args;
34 typename promote_args<T_prob>::type lp(0.0);
38 "Size of number of trials variable", ns.size(),
39 "rows of probabilities parameter", theta.rows());
44 for (
unsigned int i = 0; i < ns.size(); ++i)
47 for (
unsigned int i = 0; i < ns.size(); ++i)
51 for (
unsigned int i = 0; i < ns.size(); ++i)
57 template <
typename T_prob>
58 typename boost::math::tools::promote_args<T_prob>::type
60 const Eigen::Matrix<T_prob, Eigen::Dynamic, 1>& theta) {
61 return multinomial_log<false>(ns, theta);
fvar< T > sum(const std::vector< fvar< T > > &m)
Return the sum of the entries of the specified standard vector.
fvar< T > lgamma(const fvar< T > &x)
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...
bool check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
Return true if the provided sizes match.
fvar< T > multiply_log(const fvar< T > &x1, const fvar< T > &x2)
bool check_simplex(const char *function, const char *name, const Eigen::Matrix< T_prob, Eigen::Dynamic, 1 > &theta)
Return true if the specified vector is simplex.
boost::math::tools::promote_args< T_prob >::type multinomial_log(const std::vector< int > &ns, const Eigen::Matrix< T_prob, Eigen::Dynamic, 1 > &theta)
bool check_nonnegative(const char *function, const char *name, const T_y &y)
Return true if y is non-negative.