pre-computation of random indices