I have a table containing elements in $[1,c]$. The elements may be repeated in the table. I want to sample $m$ unique elements from this table.
I can reduce this problem to weighted sampling without replacement. This would require me to a) count the number of times each element occurs - say element $i$ occurs $n_i$ times, b) generate random numbers $U_i^{1/n_i}, 1 \le i \le c$ , and c) pick elements corresponding to the top $m$ values (reference). Here $U_i \sim Unif([0,1])$.
If I want to do this without counting the frequency of all elements, can I use the following algorithm?
Generate a uniform random number for each row in the table.
Sort these numbers.
Pick the top $m$ values such that their corresponding elements are unique.
Notice that instead of generating one uniform random number per element, this method generates $n_i$ random numbers for element $i$. Is the above algorithm equivalent to weighted sampling without replacement?