jeudi 27 juin 2019

Permanently set seed in python

I have read several questions including those aimed specifically at numpy. I am however simply interested in permanently setting seed in(with) random and hence generate the same random float with random.random() with each call. Here's what I did:

import random
random.seed(2) 

First call:

random.random()
0.9560342718892494

Second call:

random.random()
0.9478274870593494


I could keep calling random.seed but would appreciate if someone could explain what is going on or what exactly I can do to set seed once and generate the same random float with each random.random() call.

I am currently trying to learn python so my apologies if this is very basic and already has an answer. I have read several questions before posting.




Aucun commentaire:

Enregistrer un commentaire