TL;DR: Reservoir sampling.
Given a sequence of positive real numbers q(1), q(2), ... and u(1), u(2) iid uniform [0, 1], then, for any n, the indexes of the top-K
log(u(k))/q(k)
in { 1 ... n } are distributed as independent p ∝ q(k) without replacement.


