Uniform generation of permutation with repetition at most $k$ times.

94 Views Asked by At

We have set $\{1, 2, 3, \ldots,n\}$ of numbers. We want to generate permutation of length of $m$ created of those numbers with repetition of each number at most $k$ times.

If we assume $n=5, k=2, m=3$, then we could receive: $$\{3,3,1\},$$ but not $$\{3, 3, 3\}$$ as $3$ in the second example happens to be three times in output, which is more than $k$.

Is there a way of uniform generation of such permutation in a fast way?