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

2 visualizaciones (últimos 30 días)
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..?)

Respuestas (2)

Fangjun Jiang
Fangjun Jiang el 7 de En. de 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.

John D'Errico
John D'Errico el 7 de En. de 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.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by