1 #ifndef __STAN__PROB__DISTRIBUTIONS__MULTIVARIATE__CONTINUOUS__DIRICHLET_HPP__
2 #define __STAN__PROB__DISTRIBUTIONS__MULTIVARIATE__CONTINUOUS__DIRICHLET_HPP__
4 #include <boost/math/special_functions/gamma.hpp>
5 #include <boost/random/gamma_distribution.hpp>
6 #include <boost/random/variate_generator.hpp>
43 template <
bool propto,
44 typename T_prob,
typename T_prior_sample_size,
46 typename boost::math::tools::promote_args<T_prob,T_prior_sample_size>::type
48 const Eigen::Matrix<T_prior_sample_size,Eigen::Dynamic,1>& alpha,
52 using boost::math::tools::promote_args;
53 typename promote_args<T_prob,T_prior_sample_size>::type lp(0.0);
58 for (
int k = 0; k < alpha.rows(); ++k)
62 for (
int k = 0; k < theta.rows(); ++k)
67 template <
bool propto,
68 typename T_prob,
typename T_prior_sample_size>
70 typename boost::math::tools::promote_args<T_prob,T_prior_sample_size>::type
72 const Eigen::Matrix<T_prior_sample_size,Eigen::Dynamic,1>& alpha) {
77 template <
typename T_prob,
typename T_prior_sample_size,
80 typename boost::math::tools::promote_args<T_prob,T_prior_sample_size>::type
82 const Eigen::Matrix<T_prior_sample_size,Eigen::Dynamic,1>& alpha,
84 return dirichlet_log<false>(theta,alpha,Policy());
87 template <
typename T_prob,
typename T_prior_sample_size>
89 typename boost::math::tools::promote_args<T_prob,T_prior_sample_size>::type
91 const Eigen::Matrix<T_prior_sample_size,Eigen::Dynamic,1>& alpha) {
96 inline Eigen::VectorXd
99 using boost::variate_generator;
100 using boost::gamma_distribution;
103 Eigen::VectorXd y(alpha.rows());
104 for(
int i = 0; i < alpha.rows(); i++) {
105 variate_generator<RNG&, gamma_distribution<> >
106 gamma_rng(rng, gamma_distribution<>(alpha(i,0),1));
111 for(
int i = 0; i < alpha.rows(); i++)