1 #ifndef STAN_MATH_PRIM_MAT_PROB_DIRICHLET_LOG_HPP
2 #define STAN_MATH_PRIM_MAT_PROB_DIRICHLET_LOG_HPP
4 #include <boost/math/special_functions/gamma.hpp>
5 #include <boost/random/gamma_distribution.hpp>
6 #include <boost/random/variate_generator.hpp>
42 template <
bool propto,
43 typename T_prob,
typename T_prior_sample_size>
44 typename boost::math::tools::promote_args<T_prob, T_prior_sample_size>::type
47 <T_prior_sample_size, Eigen::Dynamic, 1>& alpha) {
48 static const char*
function(
"dirichlet_log");
50 using boost::math::tools::promote_args;
52 typename promote_args<T_prob, T_prior_sample_size>::type lp(0.0);
54 "probabilities", theta,
55 "prior sample sizes", alpha);
61 for (
int k = 0; k < alpha.rows(); ++k)
65 for (
int k = 0; k < theta.rows(); ++k)
71 template <
typename T_prob,
typename T_prior_sample_size>
73 typename boost::math::tools::promote_args<T_prob, T_prior_sample_size>::type
76 <T_prior_sample_size, Eigen::Dynamic, 1>& alpha) {
77 return dirichlet_log<false>(theta, alpha);
fvar< T > lgamma(const fvar< T > &x)
boost::math::tools::promote_args< T_prob, T_prior_sample_size >::type dirichlet_log(const Eigen::Matrix< T_prob, Eigen::Dynamic, 1 > &theta, const Eigen::Matrix< T_prior_sample_size, Eigen::Dynamic, 1 > &alpha)
The log of the Dirichlet density for the given theta and a vector of prior sample sizes...
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...
bool check_positive(const char *function, const char *name, const T_y &y)
Return true if y is positive.
fvar< T > multiply_log(const fvar< T > &x1, const fvar< T > &x2)
bool check_consistent_sizes(const char *function, const char *name1, const T1 &x1, const char *name2, const T2 &x2)
Return true if the dimension of x1 is consistent with 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.