Problems Generating Scrambled Quasi-Monte Carlo Numbers in Parfor Loops
Afficher commentaires plus anciens
I am having an issue generating scrambled quasi-monte carlo numbers in parfor loops.
The problem is that when I generate multiple sets of these numbers within a parfor loop, the numbers in each set end up being identical. I am including a very simple example below.
D = 3;
M = 1000;
numbers = cell(1,4);
mystream = qrandstream(scramble(sobolset(D),'MatousekAffineOwen'));
myfun = @(x) qrand(mystream,x);
parfor i = 1:4
numbers{i} = myfun(M);
end
To demonstrate the issue, after running this code, the numbers in numbers{1}, numbers{2}, numbers{3} and numbers{4} are identical as:
>>numbers{1}(1:3,:)
ans =
0.76 0.05 0.77
0.33 0.96 0.23
0.60 0.72 0.52
>> numbers{2}(1:3,:)
ans =
0.76 0.05 0.77
0.33 0.96 0.23
0.60 0.72 0.52
I'm wondering whether anyone can think of a fix for this issue. I figure there must be something that I can do, as the problem does not occur when I use a normal random stream of numbers.
I should mention that it will not be possible for me to exploit something like the 'Skip' or 'Leap' properties of Quasi-Random Number streams. The reason is that I use the snippet of code above in a larger MATLAB program that I run in parallel...
Réponse acceptée
Plus de réponses (1)
Oleg Komarov
le 6 Avr 2012
0 votes
Give a look at:
Especially comments 8, and 9.
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!