Sorry for the convoluted title. Basically, my question is: can we say that the sequence produced by the following sequence()
function is pseudo-random?
import numpy as np
def sequence(int n):
x = np.empty(n, dtype=int)
for i in range(n):
np.random.seed(i)
x[i] = np.random.randint(100)
return x
Note that the seed is set every time before sampling one (pseudo)random integer, not just once before generating all the samples, but the seed changes every time.
For a bit of context, the reason why I am interested in knowing this is that I need to generate a set of objects, each of which needs to sample a set of properties. Each object has a given ID (a progressive integer) and I thought I could use it as seed to instanciate a random number generator for each object. This would ensure that each instance is “reproducible by ID”. For sake of example, say that the objects represent people and the first property sampled every time is their age. If the answer to my original question is “no, sequence()
does not produce a pseudo-random array“, then it would mean that the sequence of ages generated for a list of people would not be pseudo-random – which is precisely what I want to avoid!