psychopy.org | Reference | Downloads | Github

Setting random seed for DotStim

randomization

#1

I wish to use a DotStim object. However, I would like the exact trajectories to be reproducible. One easy way to do this is to set the random seed before using the DotStim. However, I have tried setting
random.seed( a_number )
Yet, the dot motions is different every time I run the program (I made the dot motion slow enough that I can visually see that the two instances are not identical).

Thus, my question: Is it possible to set the seed used by the object DotStim to a specific value such that every time the program is started, the dots are exactly the same?

Thanks, D.


#2

You could try doing something like psychopy.visual.dot.numpy.random.seed(a_number), which seems to work for me. You likely need to have created a dummy DotStim first, before creating your intended DotStim, so that the imports have happened.


#3

Great, thank you. Indeed, the dummy Dot object is required. Thus

dummy = visual.DotStim(win)
visual.dot.numpy.random.seed(123)

did it!