【发布时间】:2015-01-06 15:40:22
【问题描述】:
这对我来说似乎是一个错误。似乎有必要在 Matlab 中调用 rng() 两次才能获得所需的种子。考虑以下实验:
>> sd = rng(3) % THIS DOES NOT WORK
sd =
Type: 'twister'
Seed: 0
State: [625x1 uint32]
>> sd = rng(3) % BUT NOW IT DOES
sd =
Type: 'twister'
Seed: 3
State: [625x1 uint32]
>> sd = rng(3) % AND AGAIN, TO CONFIRM
sd =
Type: 'twister'
Seed: 3
State: [625x1 uint32]
>> sd = rng('shuffle') % BUT THIS FAILS
sd =
Type: 'twister'
Seed: 3
State: [625x1 uint32]
>> sd = rng('shuffle') % BUT ON THE SECOND GO IT WORKS
sd =
Type: 'twister'
Seed: 87326715
State: [625x1 uint32]
>> sd = rng('shuffle') % AND ON THE THIRD
sd =
Type: 'twister'
Seed: 87326802
State: [625x1 uint32]
>> sd = rng(4) % BUT AGAIN THIS FAILS
sd =
Type: 'twister'
Seed: 87326987
State: [625x1 uint32]
>> sd = rng(4) % BUT ON THE SECOND GO IT WORKS AGAIN
sd =
Type: 'twister'
Seed: 4
State: [625x1 uint32]
>> sd = rng(4) % AND SO ON
sd =
Type: 'twister'
Seed: 4
State: [625x1 uint32]
【问题讨论】: