1 #ifndef __STAN__PROB__DISTRIBUTIONS__MULTIVARIATE__DISCRETE__MULTINOMIAL_HPP__
2 #define __STAN__PROB__DISTRIBUTIONS__MULTIVARIATE__DISCRETE__MULTINOMIAL_HPP__
17 template <
bool propto,
20 typename boost::math::tools::promote_args<T_prob>::type
22 const Eigen::Matrix<T_prob,Eigen::Dynamic,1>& theta,
24 static const char*
function =
"stan::prob::multinomial_log(%1%)";
29 using boost::math::tools::promote_args;
31 typename promote_args<T_prob>::type lp(0.0);
43 for (
unsigned int i = 0; i < ns.size(); ++i)
46 for (
unsigned int i = 0; i < ns.size(); ++i)
50 for (
unsigned int i = 0; i < ns.size(); ++i)
56 template <
bool propto,
58 typename boost::math::tools::promote_args<T_prob>::type
60 const Eigen::Matrix<T_prob,Eigen::Dynamic,1>& theta) {
64 template <
typename T_prob,
66 typename boost::math::tools::promote_args<T_prob>::type
68 const Eigen::Matrix<T_prob,Eigen::Dynamic,1>& theta,
70 return multinomial_log<false>(ns,theta,Policy());
74 template <
typename T_prob>
75 typename boost::math::tools::promote_args<T_prob>::type
77 const Eigen::Matrix<T_prob,Eigen::Dynamic,1>& theta) {
var multiply_log(const var &a, const var &b)
Return the value of a*log(b).
var lgamma(const stan::agrad::var &a)
The log gamma function for variables (C99).
var sum(const Eigen::Matrix< var, R, C > &m)
Returns the sum of the coefficients of the specified matrix, column vector or row vector.
bool check_simplex(const char *function, const Eigen::Matrix< T_prob, Eigen::Dynamic, 1 > &theta, const char *name, T_result *result, const Policy &)
Return true if the specified vector is simplex.
boost::math::tools::promote_args< T_a, T_b >::type multiply_log(T_a a, T_b b)
bool check_nonnegative(const char *function, const T_y &y, const char *name, T_result *result, const Policy &)
boost::math::policies::policy default_policy
Default error-handling policy from Boost.
bool check_size_match(const char *function, T_size1 i, T_size2 j, T_result *result, const Policy &)
boost::math::tools::promote_args< T_prob >::type multinomial_log(const std::vector< int > &ns, const Eigen::Matrix< T_prob, Eigen::Dynamic, 1 > &theta, const Policy &)
Probability, optimization and sampling library.
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...