outputs from randg not repeatable with the same random seed
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens
Hi, I have a lengthy simulation program composed of many m-files (in total about 1000 lines). It uses several different random number generators (rand, randn, poissrnd, gamrnd, etc) and use these very numerous times. I set a random seed using rng at the very beginning of the main program that calls other m-files. I just noticed that outcomes from the program were not repeatable even though I use the same seed. I examined the code carefully and pinpointed that the matlab function randg is causing this problem. I placed rand(1) just before and after randg and sometimes (not always) rand(1) placed after randg gives a different number. Strangly, the different numbers are not any number; it is from a small set of numbers. Although I ran my code many times to check this issue, so far I have seen only 3-4 different numbers generated from the rand(1) placed after randg. Has anyone encountered this type of problems with randg before? What would be the reason for this? Would it be possible there may be some numerical errors in randg function? Is there anyway this problem can be resolved? Thank you.
Réponses (1)
Steven Lord
le 25 Avr 2016
I can't reproduce this behavior. Please post the following information:
- Which release of MATLAB and Statistics and Machine Learning Toolbox (previously just called Statistics Toolbox) are you using?
- What operating system are you using? Be as specific as you can; for instance, if you're using Windows say whether you're using Windows 7, Windows 8, Windows 10, etc.
- What is the output of this command:
which -all randg
- Show a SMALL section of code (no more than 10 lines) that demonstrates the problem.
1 commentaire
Etsuko
le 25 Avr 2016
Modifié(e) : Walter Roberson
le 25 Avr 2016
Cette question est clôturée.
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!