Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,532

Can't you, please, post the code?

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 86,786

Okay, I am now pretty sure of it's accuracy:

```
maze[]:=Module[{box, L={0,0,0,0}},
firstmove=RandomInteger[{1,4}];
If[firstmove==1, box=1;L[[4]]=1];
If[firstmove==2, box=2;L[[4]]=2];
If[firstmove>2, box=3;L[[4]]=3];
Do[
move=RandomInteger[{1,2}];
If [box==1 && move==1,L[[1]]=1;Return[L]];
If [box==1 && move==2,box=2];
move=RandomInteger[{1,3}];
If [box==2 && move==1,box=1];
If [box==2 && move==2,L[[2]]=1;Return[L]];
If [box==2&& move==3,box=3];
move=RandomInteger[{1,3}];
If [box==3&& move==1,box=2];
If [box==3 && move>1,L[[3]]=1;Return[L]],
{100}]
]
ans =Table[maze[],{1000000}];
(Select[ans,#[[3]]==1 && Last[#]==1&]//Length)/(Select[ans,#[[3]]==1 &]//Length)
0.07703891543158152
```

**In mathematics, you don't understand things. You just get used to them.Of course that result can be rigorously obtained, but who cares?Combinatorics is Algebra and Algebra is Combinatorics.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,532

Shouldn't you be checking if Last[#] is 1. That is where he enters.

And what is the rest of the list L for?

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 86,786

The list L contains all that information.

**In mathematics, you don't understand things. You just get used to them.Of course that result can be rigorously obtained, but who cares?Combinatorics is Algebra and Algebra is Combinatorics.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,532

But, shouldn't you be checking if the third element is 1 and the fourth is 1?

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 86,786

L[[4]] has the room the rat entered in

L[[1...3]] Has either a 1 or a 0. For instance L={0,1,0,3} would mean the rat entered the maze in room 3 and exited from room 2. L={1,0,0,2} would mean the rat entered the maze in room 2 and exited from room 1.

**In mathematics, you don't understand things. You just get used to them.Of course that result can be rigorously obtained, but who cares?Combinatorics is Algebra and Algebra is Combinatorics.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,532

Then that means you are selecting the cases where the rat has entered in room 3 and left at room 1!

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 86,786

Yikes, that is correct. I told you not to rush me! I have adjusted the code.

Of course that result can be rigorously obtained, but who cares?

Combinatorics is Algebra and Algebra is Combinatorics.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,532

You need #[[3]]==1 in the second select as well.

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 86,786

Hi;

No, that is correct. Last[L] == 1 says it entered the maze in room 1.

Of course that result can be rigorously obtained, but who cares?

Combinatorics is Algebra and Algebra is Combinatorics.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,532

Oh, I tought that was for c).

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 86,786

That is what I did it for:

(c) If the rat leaves the maze from Room 3 find the probability that it entered at Room 1.

Of course that result can be rigorously obtained, but who cares?

Combinatorics is Algebra and Algebra is Combinatorics.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,532

Well, that probability is P(entered at 1 and left at 3)/P(left at 3). That means the second Select selects the cases when the rat left at three, i.e. when #[[3]]==1.

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 86,786

Hmmm, I think it should be

( the cases it left at 3 and started at 1) / (cases it started at 1 ).

That is what I have calculated.

Of course that result can be rigorously obtained, but who cares?

Combinatorics is Algebra and Algebra is Combinatorics.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,532

That is not correct. That will give you the answer for a).

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 86,786

Hi;

How about this way of thinking;

Out of 1000000 tries the rat started in room 1, 250077 times. About 1 / 4 which is

just what we expect. The number of times it left room 3 after starting in room 1 is

38522

38522 / 250077 = 0.15404 which is just what I am getting with mine.

Of course that result can be rigorously obtained, but who cares?

Combinatorics is Algebra and Algebra is Combinatorics.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,532

Yes, but that still answers a).

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 86,786

Maybe the answers are the same? Is there something wrong with what I did in post #416?

Of course that result can be rigorously obtained, but who cares?

Combinatorics is Algebra and Algebra is Combinatorics.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,532

Yes, there is.

Do we agree that the probability we are looking for is P(entered at 1|left at 3)?

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 86,786

Yes, that looks good.

Of course that result can be rigorously obtained, but who cares?

Combinatorics is Algebra and Algebra is Combinatorics.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,532

And, do you agree that P(A|B)=P(A and B)/P(B)?

*Last edited by anonimnystefy (2013-03-31 13:58:24)*

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 86,786

Yes, that is the definition.

Of course that result can be rigorously obtained, but who cares?

Combinatorics is Algebra and Algebra is Combinatorics.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,532

That means that P(entered at 1|left at 3)=P(entered at 1 and left at 3)/P(left at 3).

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 86,786

Hmmmm, hard to argue with that one. By golly I think you are right. I did not look at it that way.

Of course that result can be rigorously obtained, but who cares?

Combinatorics is Algebra and Algebra is Combinatorics.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,532

Well, there you have it. What is the new result?

Here lies the reader who will never open this book. He is forever dead.

Offline