How can I repeat the previous state of the random generator?
2 次查看(过去 30 天)
显示 更早的评论
Hi,
I want to repeat the last (or any previous) random sequence that I just generated, but I didn't save the random stream state. It is possible to obtain the previous state if I know the current state?
Thanks in advance.
0 个评论
回答(2 个)
Matt J
2018-2-15
Is the sequence the first you generated since you started up MATLAB? If so, just restart MATLAB and save the state upon startup. It always starts up in the same state.
0 个评论
Jan
2018-2-15
编辑:Jan
2018-2-15
In theory it is possible to determine the previous state if you know the current one, because the random number generator is a simple and deterministic program. In practice it can be very expensive.
It is much easier to store the current state, if you need it later.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Random Number Generation 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!