mardi 6 janvier 2015

Why is it necessary to call rng() twice in Matlab

This seems like a bug to me. It seems like it is necessary to call rng() twice in Matlab to get the desired seeding. Consider the following experiments:



>> 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]




Aucun commentaire:

Enregistrer un commentaire