필터 지우기
필터 지우기

set the state for the random number generator

조회 수: 7 (최근 30일)
jack
jack 2011년 3월 31일
댓글: Steven Lord 2018년 5월 21일
For the function "randn", one can use
randn('state',100);
to set the state.
How about the generator "*poissrnd*"?
  댓글 수: 2
Molalign Adam Bogale
Molalign Adam Bogale 2018년 5월 21일
how can control random number generated by poissrnd?
Steven Lord
Steven Lord 2018년 5월 21일
Use the rng function.

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

채택된 답변

the cyclist
the cyclist 2011년 4월 1일
편집: John Kelly 2015년 3월 2일
If you are using an older version of MATLAB, then setting the state for rand (rather than randn) will set the state for poissrnd as well.
However, if you are using a relatively new version of MATLAB, the preferred method is to set the random number stream via RandStream:
stream = RandStream('mt19937ar','Seed',28);
RandStream.setDefaultStream(stream);
where you should put some integer where I put "28".
You can read more in the help file for RandStream, or lots more detail here: http://www.mathworks.com/help/matlab/ref/randstream.html.
I believe all the random number generators work off of the stream, but I am not 100% sure of that. I did verify that I got the same sequence of numbers from poissrnd after setting the seed like this.
  댓글 수: 1
jack
jack 2011년 4월 1일
stream = RandStream('mt19937ar','Seed',28);
RandStream.setDefaultStream(stream);
For the matlab I used(R2010b), this works well. Thanks.

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by