Does using rng guarantee having exactly the same result in each simulation?

1 回表示 (過去 30 日間)
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020 年 4 月 25 日
I am using rng to be able to reproduce data in each simulation. But I noticed there is a slightly difference for the result in each simulation (around 1%). Is it normal?
  7 件のコメント
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020 年 4 月 25 日
@Stephen Cobeldick:
My qustion was that when I use rng(1) in the loop I get different answer compared to when I use rng(1) on its own (around 1% of difference).
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020 年 4 月 25 日
@Walter Roberson:
I edited the comment and added clearer explanation (more clue):
I am using rng in a loop sth like this:
for i=1:..
for rng_idx=10:-1:1
rng(rng_idx,'twister');
...
end
end
for i=1 and rng_idx=1 I get the same answer compared to when not having for loop for rng_idx and with setting rng(1). But for the rest, I get different answer e.g. I mean for i=2 and rng_idx=1 I get different answer when I used for i=2 without any loop for rng and with setting rng(1)

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by