random number generation initial state

조회 수: 1 (최근 30일)
mehmet umut caglar
mehmet umut caglar 2012년 9월 12일
답변: Chuck 2016년 5월 5일
what is the possibility of rng('shuffle') to set the system to a specific state.
say I have a code
rng('shuffle')
A=random('unif',0,1,1,5);
say I run this code in 2 different computers. What is the possibility for these 2 guys give the same A?

답변 (2개)

Matt Tearle
Matt Tearle 2012년 9월 12일
Digging through the code, rng(shuffle) calls RandStream.shuffleSeed. In there you can find a comment:
% Create a seed based on 1/100ths of a second, this repeats itself
% about every 497 days.
So, if we believe that, the chances of getting the same seed are about 1 in 3600*24*497*100 = 4.3 billion. Now that's assuming you're just running these at two randomly chosen times (on the same computer or not).
If you run the code on one computer, then go to another and run it there, that comment implies that there's no chance they'll be the same (unless you can run the two programs within 0.01 seconds of each other).
(Of course, the two computers' clocks are probably not perfectly in sync, either.)
  댓글 수: 1
Matt Fig
Matt Fig 2012년 9월 12일
편집: Matt Fig 2012년 9월 12일
My only question was whether or not Random uses RandStream or something else because Random is a Simulink function. I have very little experience with SimuLink so I don't know how it interacts with the MATLAB core.
EDIT I see there is a non-Simulink function with the same name in the Stats TB. This is probably what is referred to here.

댓글을 달려면 로그인하십시오.


Chuck
Chuck 2016년 5월 5일
It is extremely unlikely if you are using rng("shuffle"). Practically, you should not get the exact same seed.

카테고리

Help CenterFile Exchange에서 Random Number Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by