Is there an easy way to get discrete parameters by applying floor and ceiling to a real value? For context, I have approximated an unknown population size, N, into a real-valued parameter (so I don’t run into any gradient problems) but some data,x, that I have that depend on the population size are discrete. Conceptually, I want to interpolate between the log-likelihood evaluated at floor(N) and ceiling(N) and include this in the log-likelihood as

My suggestions, in the order of whether I’d actually recommend doing them:

Just marginalize over the unknown discrete population size, which would let you work with the actual generative model that you wish to assume.

Use the “continuous binomial distribution” (write your own stan function for it) given by taking the binomial lpmf and replacing the factorials in the normalization constant with gamma functions.

Use the aforementioned continuous binomial distribution to compute the lpmf at the rounded values, and then run your interpolation scheme (not recommended; included here just in case there’s actually some deep and esoteric reason for wanting linear interpolation between the integers and for completeness a solution to your question as posed)