is generating a random value n times the same as generating a large amount of values and randomly choosing n of them?

44 Views Asked by At

I'm fairly sure that it's the same but I just wanted to make sure, since a lot of stuff about statistics are counterintuitive

is this code

from scipy.stats import binom
distribution = binom(1000, 0.23, 0)
ls = []
for i in range(200000):
    ls.append( int( distribution.rvs() ) )

the same as

from scipy.stats import binom
from random import random
distribution = binom(1000, 0.23, 0)
values = distribution.rvs(size=1000000)

for i in range(200000):
    ls.append( int(values[int(random()*len(values) - 1)]) )

Thanks

1

There are 1 best solutions below

1
On

I do think it is the same. It would not be the same if you were to generate $n$ values (one time) but whenever it chose one, that same number could not be chosen again.

But since there can be repeated values, I truly think it is the same. Hope this helped!