1#ifndef STAN_MATH_PRIM_PROB_DIRICHLET_MULTINOMIAL_LPMF_HPP
2#define STAN_MATH_PRIM_PROB_DIRICHLET_MULTINOMIAL_LPMF_HPP
58template <
bool propto,
typename T_prior_size,
59 require_eigen_col_vector_t<T_prior_size>* =
nullptr>
61 const std::vector<int>& ns,
const T_prior_size& alpha) {
62 static const char* function =
"dirichlet_multinomial_lpmf";
64 "rows of prior size parameter", alpha.rows());
66 const auto& alpha_ref =
to_ref(alpha);
87 lp +=
lbeta(a_sum, n_sum)
92 partials<0>(ops_partials)
97 return ops_partials.build(lp);
100template <
typename T_prior_size>
102 const std::vector<int>& ns,
const T_prior_size& alpha) {
103 return dirichlet_multinomial_lpmf<false>(ns, alpha);
return_type_t< T_prior_size > dirichlet_multinomial_lpmf(const std::vector< int > &ns, const T_prior_size &alpha)
The log of the Dirichlet-Multinomial probability for the given integer vector and a vector of prior ...
select_< as_operation_cl_t< T_condition >, as_operation_cl_t< T_then >, as_operation_cl_t< T_else > > select(T_condition &&condition, T_then &&then, T_else &&els)
Selection operation on kernel generator expressions.
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
T as_array_or_scalar(T &&v)
Returns specified input value.
void check_nonnegative(const char *function, const char *name, const T_y &y)
Check if y is non-negative.
fvar< T > lbeta(const fvar< T > &x1, const fvar< T > &x2)
fvar< T > log(const fvar< T > &x)
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
void check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
Check if the provided sizes match.
auto as_value_array_or_scalar(T &&v)
Extract the value from an object.
auto make_partials_propagator(Ops &&... ops)
Construct an partials_propagator.
void check_positive_finite(const char *function, const char *name, const T_y &y)
Check if y is positive and finite.
fvar< T > digamma(const fvar< T > &x)
Return the derivative of the log gamma function at the specified argument.
typename partials_return_type< Args... >::type partials_return_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Extends std::true_type when instantiated with zero or more template parameters, all of which extend t...
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...