 #include <stan/math/prim/mat/fun/log_softmax.hpp>
 #include <stan/math/prim/mat/fun/log_sum_exp.hpp>
 #include <stan/math/prim/mat/fun/sum.hpp>
 #include <stan/math/prim/scal/meta/include_summand.hpp>
 #include <boost/math/tools/promotion.hpp>
 #include <vector>

 namespace stan {
 namespace math {

 // CategoricalLog(ntheta) [0 < n <= N, theta unconstrained], no checking
 template <bool propto, typename T_prob>
 typename boost::math::tools::promote_args<T_prob>::type categorical_logit_lpmf(
 int n, const Eigen::Matrix<T_prob, Eigen::Dynamic, 1>& beta) {
 static const char* function = "categorical_logit_lpmf";

 check_bounded(function, "categorical outcome out of support", n, 1,
 beta.size());
 check_finite(function, "log odds parameter", beta);

 if (!include_summand<propto, T_prob>::value)