MATLAB Answers

Matlab: what happends under the hood when choosing 2 seeds far away with rng

2 views (last 30 days)
OD
OD on 7 Jan 2020
Answered: John D'Errico on 7 Jan 2020
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 Comments

Sign in to comment.

Answers (2)

Fangjun Jiang
Fangjun Jiang on 7 Jan 2020
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 Comments

Sign in to comment.


John D'Errico
John D'Errico on 7 Jan 2020
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 Comments

Sign in to comment.

Sign in to answer this question.

Products


Release

R2018b