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

3 ビュー (過去 30 日間)
OD 2020 年 1 月 7 日

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 件のコメント

サインイン to comment.

### 回答 (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 件のコメント

サインイン to comment.

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 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。

R2018b

Translated by