Suppose I want to generate a bunch of binary number generators given the success probabilities. One concern I have is about the random seed. The random seeds for f1, f2, f3 are their creation time, right? And the seeds are fixed for each function regardless of the random seed in the global namespace, right?
def f(p):
import random, time
random.seed(time.time())
def g():
return 1 if random.random() < p else 0
return g
f1 = f(0.05)
f2 = f(0.65)
f3 = f(0.25)
Aucun commentaire:
Enregistrer un commentaire