I want to sample from the integers $\{1, \dots, k\}$ with probabilities $\{ p_i \}_{i=1}^k$, with replacement, until I see $m$ distinct elements (call that $n$ times).
You can view the distribution I want to sample from as a multinomial distribution, but instead of fixing the number of samples $n$, let $n$ be the first number that gives an exactly $m$-sparse vector. (Alternatively, the maximal number that gives an $m$-sparse vector would also be okay.)
Using an alias method, implementing sampling literally as written above takes $O(n + k)$ time.
So, whether this is efficient to run depends on how big $n$ is. If the probabilities are relatively uniform and/or $k \gg m$, this shouldn't be too bad. But in a pathological case where $k = m + 1$ and two of the $p_i$s are extremely small, this will take a very long time.
This is a version of the coupon collector's problem, of which I've found non-uniform variants, but I haven't found one where you only need to get $m < k$ of the varieties of coupons – and anyway, I don't know if that line of reasoning will help with a more efficient sampling algorithm.
So:
- Can you find, or bound, the distribution of $n$? Particularly in terms of $\max p_i / \min p_i$ or similar?
- Is there a more efficient algorithm to perform this sampling?