1 #ifndef STAN_MATH_PRIM_SCAL_PROB_BINOMIAL_LOGIT_LPMF_HPP 2 #define STAN_MATH_PRIM_SCAL_PROB_BINOMIAL_LOGIT_LPMF_HPP 35 template <
bool propto,
typename T_n,
typename T_N,
typename T_prob>
38 const T_prob& alpha) {
42 static const char*
function =
"binomial_logit_lpmf";
47 T_partials_return logp = 0;
52 "Population size parameter", N,
53 "Probability parameter", alpha);
66 for (
size_t i = 0; i <
size; ++i)
72 for (
size_t i = 0; i <
length(alpha); ++i)
77 for (
size_t i = 0; i <
length(alpha); ++i)
80 for (
size_t i = 0; i <
size; ++i)
81 logp += n_vec[i] * log_inv_logit_alpha[i]
82 + (N_vec[i] - n_vec[i]) * log_inv_logit_neg_alpha[i];
85 T_partials_return temp1 = 0;
86 T_partials_return temp2 = 0;
87 for (
size_t i = 0; i <
size; ++i) {
89 temp2 += N_vec[i] - n_vec[i];
92 ops_partials.
edge1_.partials_[0]
98 for (
size_t i = 0; i <
size; ++i)
99 ops_partials.
edge1_.partials_[i]
105 return ops_partials.
build(logp);
108 template <
typename T_n,
typename T_N,
typename T_prob>
110 const T_n& n,
const T_N& N,
const T_prob& alpha) {
111 return binomial_logit_lpmf<false>(n, N, alpha);
void check_finite(const char *function, const char *name, const T_y &y)
Check if y is finite.
boost::math::tools::promote_args< double, typename partials_type< typename scalar_type< T >::type >::type, typename partials_return_type< T_pack... >::type >::type type
fvar< T > binomial_coefficient_log(const fvar< T > &x1, const fvar< T > &x2)
void check_bounded(const char *function, const char *name, const T_y &y, const T_low &low, const T_high &high)
Check if the value is between the low and high values, inclusively.
T value_of(const fvar< T > &v)
Return the value of the specified variable.
Extends std::true_type when instantiated with zero or more template parameters, all of which extend t...
scalar_seq_view provides a uniform sequence-like wrapper around either a scalar or a sequence of scal...
This template builds partial derivatives with respect to a set of operands.
fvar< T > inv_logit(const fvar< T > &x)
Returns the inverse logit function applied to the argument.
size_t length(const std::vector< T > &x)
Returns the length of the provided std::vector.
bool size_zero(T &x)
Returns 1 if input is of length 0, returns 0 otherwise.
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...
void check_nonnegative(const char *function, const char *name, const T_y &y)
Check if y is non-negative.
boost::math::tools::promote_args< double, typename scalar_type< T >::type, typename return_type< Types_pack... >::type >::type type
return_type< T_prob >::type binomial_logit_lpmf(const T_n &n, const T_N &N, const T_prob &alpha)
Binomial log PMF in logit parametrization.
size_t max_size(const T1 &x1, const T2 &x2)
T_return_type build(double value)
Build the node to be stored on the autodiff graph.
VectorBuilder allocates type T1 values to be used as intermediate values.
int size(const std::vector< T > &x)
Return the size of the specified standard vector.
void check_consistent_sizes(const char *function, const char *name1, const T1 &x1, const char *name2, const T2 &x2)
Check if the dimension of x1 is consistent with x2.
fvar< T > log_inv_logit(const fvar< T > &x)
internal::ops_partials_edge< double, Op1 > edge1_