Think about Loose Coupling PerlMonks

### Re: Running a simulation - expected outcome

by BrowserUk (Pope)
 on Sep 29, 2012 at 20:20 UTC ( #996421=note: print w/replies, xml ) Need Help??

in reply to Running a simulation - expected outcome

The difference is that at any step point, his algorithm can only chose from a maximum (less when near edges) of 84 squares -- a 13 x 13 diamond pattern -- surrounding his current position.

Your code, by virtue of not tracing a path, but simply picking any random square from the full set, has the full 10,000 choices each time.

To correctly calculate his odds, you would need to factor in the odds of one or more of those 84 possibilities being contaminated, and then 1:84 chance that he will pick one of them.

Ie. His odds of contamination are less, because he has less chance of reaching all of the cells. Or rather, any given contaminated cell.

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
• Comment on Re: Running a simulation - expected outcome

Replies are listed 'Best First'.
Re^2: Running a simulation - expected outcome
by BillKSmith (Vicar) on Sep 30, 2012 at 04:00 UTC

Your analysis is based on the probablity of infection. The original analysis is based on the probablility of avoiding infection. It seems to me the result should be the same. I do see a minor "off by one" error in the original because it ignores the fact that he cannot move to the uninfected cell that he is already on.

Bill

Okay. But surely, one is just 1 - the other.

I reckon the answer to be 0.373 / 0.617 on the basis of my own simulation; but I cannot make the math fit.

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: Running a simulation - expected outcome
by hippo (Abbot) on Oct 01, 2012 at 16:46 UTC

That isn't my reading of his algorithm. It looks to me like it can only choose 1 out of 24 squares - there isn't the possibility of moving diagonally. Also the mod means that the edge effects (should) disappear.

The difference between the two simulations is as you say, however: he is constrained to the limited path but Cristoforo is not.

That isn't my reading of his algorithm.

You are probably right.

I took cristoforo's description of the algorithm -- which includes this passage "moving randomly 1 to 6 cells" -- as correct. Looking back to the originator's code, I do not know where than came from, but I didn't look very hard now, or at all before posting.

there isn't the possibility of moving diagonally.

Hm. It depends how you interpret the phrase: moving randomly 1 to 6 cells, (up, down, left or right),, that not quite the same as "not diagonally". I took to mean that move 5 UP and 1 LEFT was a valid move. Hence I came up with my "13 x 13 diamond pattern" and 1:84:

```......X......
.....XXX.....
....XXXXX....
...XXXXXXX...
..XXXXXXXXX..
.XXXXXXXXXXX.
XXXXXX.XXXXXX
.XXXXXXXXXXX.
..XXXXXXXXX..
...XXXXXXX...
....XXXXX....
.....XXX.....
......X......
[download]```

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
Yes, the specs say either of 1 way (up 1 to 6, right 1 to 6, down 1 to 6 or left 1 to 6, where a number is randomly chosen from 1 to 6 for each step).

Log In?
 Username: Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://996421]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2018-04-26 13:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My travels bear the most uncanny semblance to ...

Results (96 votes). Check out past polls.

Notices?