Reputation: 171
What is the difference in
a = numpy.random.RandomState(1)
b = a.rand()
compared to
b = numpy.random.rand()
I'm not really sure if this has to do with seeding, and I'm new to the concept of seeding. If this is a case of seeding could somebody explain how the RandomState
method does that, and maybe any tips on when it's useful to seed. Thank you.
Upvotes: 1
Views: 1066
Reputation: 121
The first sentence (a = numpy.random.RandomState(1)
) start the pseudo random seed, in your case 1. That means that, no mater how many times you run the script, always get the same "random" number.
In the second case (b = numpy.random.rand()
), the seed is predefined, you don't know what seed was used. So, every time you run a script, you obtain the next pseudo random of the unknown seed.
Upvotes: 4