How different do random seeds need to be?

前端 未结 6 1374
情深已故
情深已故 2020-12-06 16:28

Consider code like this (Python):

import random

for i in [1, 2, 3, 4]:
    random.seed(i)
    randNumbers = [random.rand() for i in range(100)] # initialize         


        
6条回答
  •  遥遥无期
    2020-12-06 17:19

    If your random number generator is high quality, it shouldn't matter how you seed it. In fact, the best practice would be to seed it only once. Random number generators are designed to have certain statistical behavior once they're started. Frequently reseeding effectively creates a different random number generator, one that may not be as good.

    Randomly selecting seeds sounds like a good idea, but it isn't. In fact, because of the "birthday paradox," there's a surprisingly high probability that you'll pick the same seed twice.

提交回复
热议问题