1 #ifndef __STAN__PROB__DISTRIBUTIONS__UNIVARIATE__DISCRETE__HYPERGEOMETRIC_HPP__
2 #define __STAN__PROB__DISTRIBUTIONS__UNIVARIATE__DISCRETE__HYPERGEOMETRIC_HPP__
18 template <
bool propto,
30 static const char*
function =
"stan::prob::hypergeometric_log(%1%)";
53 if (!
check_bounded(
function, n, 0, a,
"Successes variable", &logp, Policy()))
55 if (!
check_greater(
function, N, n,
"Draws parameter", &logp, Policy()))
57 for (
size_t i = 0; i < size; i++) {
58 if (!
check_bounded(
function, N_vec[i]-n_vec[i], 0, b_vec[i],
"Draws parameter minus successes variable", &logp, Policy()))
60 if (!
check_bounded(
function, N_vec[i], 0, a_vec[i]+b_vec[i],
"Draws parameter", &logp, Policy()))
65 "Successes variable",
"Draws parameter",
"Successes in population parameter",
"Failures in population parameter",
74 for (
size_t i = 0; i < size; i++)
82 template <
bool propto,
96 template <
typename T_n,
108 return hypergeometric_log<false>(n,N,a,b,Policy());
111 template <
typename T_n,
boost::math::tools::promote_args< T_N, T_n >::type binomial_coefficient_log(T_N N, T_n n)
Return the log of the binomial coefficient for the specified arguments.
bool check_greater(const char *function, const T_y &y, const T_low &low, const char *name, T_result *result, const Policy &)
bool check_consistent_sizes(const char *function, const T1 &x1, const T2 &x2, const char *name1, const char *name2, T_result *result, const Policy &)
bool check_bounded(const char *function, const T_y &y, const T_low &low, const T_high &high, const char *name, T_result *result, const Policy &)
bool check_finite(const char *function, const T_y &y, const char *name, T_result *result, const Policy &)
Checks if the variable y is finite.
boost::math::policies::policy default_policy
Default error-handling policy from Boost.
double hypergeometric_log(const T_n &n, const T_N &N, const T_a &a, const T_b &b, const Policy &)
Probability, optimization and sampling library.
size_t length(const T &x)
size_t max_size(const T1 &x1, const T2 &x2)
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...