| Author |
Comment/Response |
Tom
|
10/01/09 00:36am
Hi,
I'm doing probabilistic simulations and am running into issues with Parallelize and ParallelDo. I have a function try[a,b] that simulates flipping a coin a times and returns true if a series of b heads is found.
Here is the problem I'm having:
x = 0;
Do[If[try[20, 7], x++], {i, 1, 100000}];
x
Out[53]: 5783
x = 0;
ParallelDo[If[try[20, 7], x++], {i, 1, 100000}];
x
Out[52]: 0
As you can see, ParallelDo is giving far different answers than Do. I think this is because since my function returns true only about 5% of the time, ParallelDo "assumes" that the function will always return false. Is there any way to stop this assumption? I just want to use multiple cores.
I attached a notebook that illustrates the problem.
Thanks.
Attachment: testcase.nb, URL: , |
|