Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.3K Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Can't get this old mathematica code to run...

Posted 11 years ago

Hello! I'm trying to get the following program to run. It seems like it was written with an older version of Mathematica. Any help is appreciated.

Failed = 0;

Hit = 0;

SetSharedVariable[Failed, Hit]

ParallelTable[x = Random[];

  ProbabilityStillGoing = (1 - ?/200)^j;


  If[ProbabilityStillGoing > x, Failed++, Hit++];

  If[Failed == Hit, Print[j]];

  , {j, 0, NUMBER}];    

Thanks in advance for your help.

POSTED BY: Fat Villager
3 Replies

So you want something like this --not exactly, I suspect, since I am not understanding the internals of the code, but this at least creates a list and computes a Mean:

Failed = 0;

Hit = 0;

NUMBER = 1000;

SetSharedVariable[Failed, Hit] 


N@Mean[Flatten@ParallelTable[x = Random[];
    ProbabilityStillGoing = (1 - \[Pi]/200)^j;
    If[ProbabilityStillGoing > x, Failed++, Hit++];
    If[Failed == Hit, j, {}],

    {j, 0, NUMBER}]
  ] 
POSTED BY: David Reiss
Posted 11 years ago
POSTED BY: Fat Villager

What are you expecting this code to do?

Note (assuming you've given NUMBER a value) that the body of your ParallelTable command ends with a semicolon and there is a semicolon after the full ParallelTable expression. So (1) the table will contain all Nulls and the output of the calculation will be suppressed. The code runs, it just does not return anything. And the Print statements may or may not execute depending on the details of what's happening inside of the code.

POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard