issue with Repeating Random Numbers in parfor-Loops
Afficher commentaires plus anciens
I want to get reproducible random number sequence in parfor-loops and tried the example in the documentation. However, the results are switching from two choices, which conflicts with the statement in the documentation.
what is the problem?
Here is the pilot code:
n = 3;
r = zeros(1,n);
parfor i = 1:n
stream = RandStream.getGlobalStream();
stream.Substream = i;
r(i) = rand;
end
r
one result is
r =
0.2646 0.2537 0.2276
another is
r =
0.2646 0.2537 0.3111
BTW, the results are produced by 2015a.
Creating random number stream explicitly can solve this problem, but it causes a significant increase in computing time when there are many parfor-loops. Is there a solution which is not expensive concerning computing time?
Réponse acceptée
Plus de réponses (1)
Gareth Thomas
le 4 Oct 2016
0 votes
1 commentaire
Eli4ph
le 5 Oct 2016
Catégories
En savoir plus sur Parallel for-Loops (parfor) dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!