Matlab: what happends under the hood when choosing 2 seeds far away with rng
조회 수: 2 (최근 30일)
이전 댓글 표시
I would like to know more precisely what happends when you choose a custom seed in Matlab (version= '9.5.0.944444 (R2018b)'), e.g.:
rng(101)
From my (limited, nut nevertheless existing) understanding of how pseudo-random number generators work, one can see the seed conceptually as choosing a position in a "very long list of pseudo-random numbers".
Question: lets say, (in my Matlab script), I choose
rng(100)
for my first computation (a sequence of instructions) and then,
rng(1e6)
for my second. Please, note that each time I do some computations it involves generating up to about 300k random numbers (each time).
-> Does that imply that I make sure there is no overlap between the sequence in the "list" starting at 100 and ending around 300k and the one starting at 1e6 and ending at 1'300'000 ? (the idead of "no overlap" comes from the fact since the rng(100) and rng(1e6) are separated by much more than 300k)
i.e. that these are 2 "independent" sequences, (as far as I remember this 'long list' would be generated by a special PRNG algorithm, most likely involing modular arithmetic..?)
댓글 수: 0
답변 (2개)
Fangjun Jiang
2020년 1월 7일
My understanding of rng(SeedNumber) is that SeedNumber is like an ID (identification number). It gives you the ablity to re-generate the exact same sequence of random numbers in case you need them to compare or re-test. Any seed number will allow you to generate any anount of random numbers.
댓글 수: 0
John D'Errico
2020년 1월 7일
The "separation" of two seeds is completely irrelevant. Separate them by 1 or 1e6, and they are just different seeds. If you use seeds of 1 and 2, you do NOT get the first and second elements from that long hypothetical list of random numbers.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!