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;endr
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?
Best Answer