Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'ParallelDo issues' topicStudent Support Forum > General > "ParallelDo issues"

Next Comment >Help | Reply To Topic
Author Comment/Response
10/01/09 00:36am


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}];

Out[53]: 5783

x = 0;
ParallelDo[If[try[20, 7], x++], {i, 1, 100000}];

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.


Attachment: testcase.nb, URL: ,

Subject (listing for 'ParallelDo issues')
Author Date Posted
ParallelDo issues Tom 10/01/09 00:36am
Re: ParallelDo issues Yuncong Ma 10/05/09 02:01am
Next Comment >Help | Reply To Topic