random number generation

what do you mean by 'seed' in MATLAB?

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2011 年 10 月 30 日

0 投票

If you type help rand or doc rand, it will explain what is seed. I always think of it as the unique ID of a serious of random numbers.
For example, if you run rand(3,1) twice, the results are different.
>> rand(3,1)
ans =
0.460483750542851
0.350395373697577
0.095045735172483
>> rand(3,1)
ans =
0.433671043922040
0.709235197729075
0.115968232562751
>>
But if you specify the seed number, you can duplicate the random number.
>> rand('seed',1);rand(3,1)
ans =
0.512908935785717
0.460483750542851
0.350395373697577
>> rand('seed',1);rand(3,1)
ans =
0.512908935785717
0.460483750542851
0.350395373697577
>>
This is useful sometimes when you try to repeat your test. You need to be able to repeat the inputs even though they are random numbers.

この質問は閉じられています。

質問済み:

2011 年 10 月 30 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by