Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I don't have an answer to your question, which could be interpreted about storing the current random state and then restarting from that state.

On the other hand, if you are not making any calls to any random generator in the intermediate steps, then you don't need to set the random seed to anything. The next random() call should start from exactly where it was stopped.

sage: set_random_seed(0)
sage: [ZZ.random_element() for _ in range(4)]
[-8, 2, 0, 0]
sage: [ZZ.random_element() for _ in range(4)]
[1, -1, 2, 1]

You can see that the random generator starts off from the same point even when I have intermediate computations.

sage: set_random_seed(0)
sage: [ZZ.random_element() for _ in range(4)]
[-8, 2, 0, 0]
sage: integrate(x^2, x)
1/3*x^3
sage: F.<a> = GF(4,'a')
sage: [ZZ.random_element() for _ in range(4)]
[1, -1, 2, 1]