Yes. When you call random.seed()
, it sets the random seed. The sequence of numbers you generate from that point forwards will always be the same.
The thing is, you're only set the seed once, and then you're calling np.random.uniform()
three times. That means you're getting the next three numbers from your random.seed()
. Of course they're different – you haven't reset the seed in between. But every time you run the program, you'll get the same sequence of three numbers, because you set the seed to the same thing before generating them all.
Setting the seed only affects the next random number to be generated, because of how pseudo-random number generation (which np.random
uses) works: it uses the seed to generate a new random number deterministically, and then uses the generated number to set a new seed for the next number. It effectively boils down to getting a really really long sequence of random numbers that will, eventually, repeat itself. When you set the seed, you're jumping to a specified point in that sequence – you're not keeping the code there, though.