1#ifndef STAN_MATH_PRIM_PROB_DISCRETE_RANGE_LCDF_HPP
2#define STAN_MATH_PRIM_PROB_DISCRETE_RANGE_LCDF_HPP
37template <
typename T_y,
typename T_lower,
typename T_upper>
39 const T_upper& upper) {
40 static constexpr const char* function =
"discrete_range_lcdf";
42 "Upper bound parameter", upper);
52 size_t N =
max_size(y, lower, upper);
54 for (
size_t n = 0; n < N; ++n) {
55 const int y_dbl = y_vec[n];
56 if (y_dbl < lower_vec[n]) {
62 for (
size_t n = 0; n < N; n++) {
63 const int y_dbl = y_vec[n];
64 if (y_dbl < upper_vec[n]) {
65 const int lower_dbl = lower_vec[n];
66 const int upper_dbl = upper_vec[n];
67 cdf +=
log(y_dbl - lower_dbl + 1) -
log(upper_dbl - lower_dbl + 1);
scalar_seq_view provides a uniform sequence-like wrapper around either a scalar or a sequence of scal...
double discrete_range_lcdf(const T_y &y, const T_lower &lower, const T_upper &upper)
Return the log CDF of a discrete range distribution for the given y, lower and upper bounds (all inte...
static constexpr double LOG_ZERO
The natural logarithm of 0, .
bool size_zero(const T &x)
Returns 1 if input is of length 0, returns 0 otherwise.
fvar< T > log(const fvar< T > &x)
void check_greater_or_equal(const char *function, const char *name, const T_y &y, const T_low &low, Idxs... idxs)
Throw an exception if y is not greater or equal than low.
void check_consistent_sizes(const char *)
Trivial no input case, this function is a no-op.
int64_t max_size(const T1 &x1, const Ts &... xs)
Calculate the size of the largest input.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...