mercredi 13 mai 2020

When functions in random module generate same results for a given seed

We might think the functions in random module would generate same results for a given seed, but in fact it doesn't that exactly, e.g. here.

The following results are expected to be reproducible, but something different was once generated abruptly. Why?

Unfortunately I did neither log the error nor could reproduce the problem so far.

import random  # python 3.8.2                                                                                                       

random.seed(0)                                                                                                        
rng = range(30)                                                                                                         
seq = [random.sample(rng, random.randint(0, 3)) for _ in rng]                                                               
print(seq)

There are only sparse statements about pseudo random reproducibility. What are potential pitfalls to use random.*, if absolute reproducibility is required?




Aucun commentaire:

Enregistrer un commentaire