jeudi 29 octobre 2020

seed for different numpy functions

    a = (np.random.rand(10) > 0.1).astype(int)
    b = np.random.binomial(1, 0.9, 10)
    c = np.random.choice([0, 1], 10, [0.1, 0.9])

There are at least 3 different ways in numpy by which I can get an array of 0 and 1 (the ones are added with a certain probability p (p=0.9 in example)). When I use np.random.seed(1), the certain method always returns the same array. However, all the above methods create different arrays even with the same seed. Is this happening because they all have different PRNG algorithms or just some of them are not affected by np.random.seed(1)?




Aucun commentaire:

Enregistrer un commentaire