I try to do a big simulation like below.
(However, I do not change the sizes I want to 10 ^ 5, 10 ^ 7, 10 ^ 9.)
n = RandomSample[all = Range[10^7], 2*10^5];
r = RandomChoice[all, 10^9];
Total@Table[Count[n, r[[i]]], {i, 1, Length[r]}]
However, the calculation takes too long.
How can I shorten the calculation time effectively?
RandomInteger
seems to cut more than 50% of the time off ofRange
andRandomSample
. It can also be used in place ofRandomChoice
if combined withTable
. $\endgroup$RandomInteger
does not produce the same results asRandomSample
. $\endgroup$RandomChoice
on the full range. Thanks. $\endgroup$