Sampling random sets of integers with bounded range

40 Views Asked by At

How can we randomly sample a set $S$ of $k$ integers from the range $[1, n]$ such that:

  1. The set satisfies $\max(S) - \min(S) \leq w$.

  2. Each integer in $[1, n]$ has an equal chance of being in the set. If this is not possible, it should be as close as possible (minimizing the variance of probability).

  3. 1 and 2 permitting, the method is as uniformly random as possible. That is, the maximum entropy distribution under constraints 1 and 2.

We have $k < w$.

Are there any efficient methods? Methods that have some bias but get close?