13.7 Discrete range distribution

13.7.1 Probability mass functions

If \(l, u \in \mathbb{Z}\) are lower and upper bounds (\(l \le u\)), then for any integer \(y \in \{l,\ldots,u\}\), \[ \text{DiscreteRange}(y ~|~ l, u) = \frac{1}{u - l + 1}. \]

13.7.2 Sampling statement

y ~ discrete_range(l, u)

Increment the target log probability density with discrete_range_lupmf(y | l, u) dropping constant additive terms.

13.7.3 Stan functions

All of the discrete range distributions are vectorized so that the outcome y and the bounds l, u can be a single integer (type int) or an array of integers (type int[]).

real discrete_range_lpmf(ints y | ints l, ints u)
The log probability mass function with outcome(s) y in \(l:u\).

real discrete_range_lupmf(ints y | ints l, ints u)
The log probability mass function with outcome(s) y in \(l:u\) dropping constant additive terms.

real discrete_range_cdf(ints y, ints l, ints u)
The discrete range cumulative distribution function for the given y, lower and upper bounds.

real discrete_range_lcdf(ints y | ints l, ints u)
The log of the discrete range cumulative distribution function for the given y, lower and upper bounds.

real discrete_range_lccdf(ints y | ints l, ints u)
The log of the discrete range complementary cumulative distribution function for the given y, lower and upper bounds.

int discrete_range_rng(ints l, ints u)
Generate a discrete variate between the given lower and upper bounds; may only be used in transformed data and generated quantities blocks.