1 #ifndef __STAN__PROB__DISTRIBUTIONS__MULTIVARIATE__DISCRETE__CATEGORICAL_HPP__
2 #define __STAN__PROB__DISTRIBUTIONS__MULTIVARIATE__DISCRETE__CATEGORICAL_HPP__
15 template <
bool propto,
18 typename boost::math::tools::promote_args<T_prob>::type
20 const Eigen::Matrix<T_prob,Eigen::Dynamic,1>& theta,
22 static const char*
function =
"stan::prob::categorical_log(%1%)";
26 using boost::math::tools::promote_args;
30 typename promote_args<T_prob>::type lp(0.0);
32 "Number of categories",
36 "Probabilities parameter",
41 return log(theta(n-1));
45 template <
bool propto,
48 typename boost::math::tools::promote_args<T_prob>::type
50 const Eigen::Matrix<T_prob,Eigen::Dynamic,1>& theta) {
55 template <
typename T_prob,
58 typename boost::math::tools::promote_args<T_prob>::type
60 const Eigen::Matrix<T_prob,Eigen::Dynamic,1>& theta,
62 return categorical_log<false>(n,theta,Policy());
65 template <
typename T_prob>
67 typename boost::math::tools::promote_args<T_prob>::type
69 const Eigen::Matrix<T_prob,Eigen::Dynamic,1>& theta) {
internal::traits< Derived >::Index size_type
var log(const var &a)
Return the natural log of the specified variable (cmath).
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.
bool check_bounded(const char *function, const T_y &y, const T_low &low, const T_high &high, const char *name, T_result *result, const Policy &)
boost::math::policies::policy default_policy
Default error-handling policy from Boost.
boost::math::tools::promote_args< T_prob >::type categorical_log(const typename Eigen::Matrix< T_prob, Eigen::Dynamic, 1 >::size_type n, 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...