Random numbers seed setting
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
I am using randn('seed', 1) at the beginning of my code for a simulation with 1000 replications. This is to make sure that if I rerun the simulation I'll get same results every time. But I am getting slightly different results in different runs. Can anyone help? I am using Matlab 2012a.
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2013년 4월 19일
Use
a=rng;
out=randn
rng(a)
out=randn
댓글 수: 6
Digitalsd
2013년 4월 19일
In addition you can use the code:
stream = RandStream('mt19937ar','seed',1);
RandStream.setGlobalStream(stream);
randn
stream = RandStream('mt19937ar','seed',1);
RandStream.setGlobalStream(stream);
randn
"mt19937ar" indicates the used p.s.random generator algorithm
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Results, Reporting, and Test File Management에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!