0
$\begingroup$

Given a uniform random number generator that generates integers between any given range, a n-tuple $b$, and an integer $c$, how can one uniformly generate n-tuples ($x$) that meet the following constraints:

$$1 \le x_i \le b_i $$ $$\sum x_i \le c$$

where $b_i > 1$ for all $i$, and where $c \ge \max(b_i) + (n-1)$?

All numbers here are positive integers.

By uniformly generate, I mean that every valid n-tuple that meets the above constraints has an equal probability of being generated.

$\endgroup$
0
$\begingroup$

One can generate $n$ random $x_i$ with uniform distribution on $\{1, \ldots, b_i\}$, and then discard the result if $\sum_i x_i \leq c$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.