You are not logged in.
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
The knowledge of some things as a function of age is a delta function.
Offline
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.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
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
The knowledge of some things as a function of age is a delta function.
Offline
The list L contains all that information.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
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
The knowledge of some things as a function of age is a delta function.
Offline
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.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
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.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.
Offline
Yikes, that is correct. I told you not to rush me! I have adjusted the code.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
You need #[[3]]==1 in the second select as well.
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
The knowledge of some things as a function of age is a delta function.
Offline
Hi;
No, that is correct. Last[L] == 1 says it entered the maze in room 1.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Oh, I tought that was for c).
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
The knowledge of some things as a function of age is a delta function.
Offline
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.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
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.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.
Offline
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.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
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.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.
Offline
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.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Yes, but that still answers a).
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
The knowledge of some things as a function of age is a delta function.
Offline
Maybe the answers are the same? Is there something wrong with what I did in post #416?
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
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.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.
Offline
Yes, that looks good.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
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.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.
Offline
Yes, that is the definition.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
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.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.
Offline
Hmmmm, hard to argue with that one. By golly I think you are right. I did not look at it that way.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Well, there you have it. What is the new result?
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
The knowledge of some things as a function of age is a delta function.
Offline