I have `m` observed return counts `k_1, ..., k_m` from repeated survey replications, and I want to infer both the common return probability `theta` and an unknown total number of surveys `n`, which is assumed discrete and bounded above by `nmax`.

My model is:
`theta ~ Uniform(0, 1),`
`n ~ DiscreteUniform(1, ..., nmax),`
`k_j | n, theta ~ Binomial(n, theta), for j = 1, ..., m.`

Because `n` is discrete and not sampled directly in Stan, the model marginalizes over all values `n = 1, ..., nmax`. Define

`lp_n = log(1 / nmax) + sum_{j=1}^m log Pr(k_j | n, theta),`

with `lp_n = -infinity` for `n < nmin`, where `nmin = max_j k_j`. The Stan target is then proportional to

`log(sum_{n=1}^{nmax} exp(lp_n)),`

and the posterior probabilities of the candidate values of `n` are obtained by normalizing `exp(lp_n)`, equivalently by a softmax transformation of the log weights `lp_n`.

Here:
`k_j` is the observed number of returns in survey replication j,
`m` is the number of replications,
`n` is the unknown total number of surveys sent,
`theta` is the common survey return probability,
`nmax` is the known upper bound on `n`,
`nmin` is the smallest feasible value of `n`, namely the maximum observed return count.
