How can I repeat the previous state of the random generator?

1 回表示 (過去 30 日間)
Jose Ercolino
Jose Ercolino 2018 年 2 月 15 日
編集済み: Jan 2018 年 2 月 15 日
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.

回答 (2 件)

Matt J
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.

Jan
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.

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by