0 . 4 ), down (with probability 0 . 5 ) or stay where he is (with probability 0 . 1 ).
A man is standing on an infinite ladder. In one move, he can either go up (with probabilityFind the probability that after 1 1 moves he is one step away from his initial position.
Inspired by this problem.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Nice. I like how you use the sum to count all the different permutations. +1!
Log in to reply
Thanks. Yes, I prefer to form a general sum whenever possible, so that it can be adapted for different parameters. (It also makes the calculation faster.)
Good problem. :)
Solved in Python using Monte Carlo sampling:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
This gave me a decent approximation at 0.2411825 .
Hey can you suggest a good place to learn these algorithms? (Websites or books)
And which do you prefer more C++ or Python ? why?
Log in to reply
This is a really awesome resource: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011
And I greatly prefer Python because it's easy to read and it's easy to code. I've noticed that most Python programmers are just happier than most programmers.
Sorry it took me so long to reply, for some reason this didn't go to my email.
1 step away: 0.241331211990001
2 steps away: 0.182990566549980
0 step away: 0.107931142010016
and etc.
Convert (0.4 U + 0.5 D + 0.1 S)^11 into two for calculations required:
(0.4 + 0.5 + 0.1)^11 consists of 3^11 i.e. 177147 branching, while
(U + D + S)^11 be assigned into (2 + 1/ 2 + 1)^11 or (1/ 2 + 2 + 1)^11 or (3 + 1/ 3 + 1)^11 and etc for identification of combination of steps,
Turn on the logic required for combination of some number of 2, 1/ 2 and 1 for example for a product of 11 elements chosen for 1/ 2 or 2 to indicate 1 move, summing up all obtained 0.241331211990001. During the process of calculation using Excel, the sums are checked to be 1 for every column to ensure correctness.
Answer required is 0.241331211990001
Note: Paste of copied cells can be eased with technique of column of cells with wanted side length with content of cells arbitrary or not being aware. Forget about binomial coefficients or nCr for this question and multiply series by series fundamentally.
Let's indicate the event 'being one step up the initial position after 11 steps' as U , and 'being one step down the initial position after 11 steps' as D . The probability of being one step away from the original position is
P ( U ∪ D ) = P ( U ) + P ( D ) .
Being one step up at the end of the process means that one more step-up has been done respect to the total steps-down. So the possible triplets are
⎣ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎡ Up 6 5 4 3 2 1 Down 5 4 3 2 1 0 Stop 0 2 4 6 8 1 0 ⎦ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎤
Considering that a single step up, down and a stop has, respectively P ( u ) = 4 2 , P ( d ) = 2 1 , P ( s ) = 1 0 1 , we can write
P ( U ) = ( 4 2 ) 6 ( 2 1 ) 5 ( 1 0 1 ) 0 ( 6 1 1 ) ( 5 5 ) + . . . + ( 4 2 ) 1 ( 2 1 ) 0 ( 1 0 1 ) 1 0 ( 1 1 1 ) ( 0 1 0 ) = i = 1 ∑ 6 ( 4 2 ) i ( 2 1 ) i − 1 ( 1 0 1 ) 1 2 − 2 i ( i 1 1 ) ( i − 1 1 1 − i )
as well for the probability of being one step down at the 11th step, we can reason in the same way just switching the Up/Down columns
P ( D ) = i = 1 ∑ 6 ( 2 1 ) i ( 4 2 ) i − 1 ( 1 0 1 ) 1 2 − 2 i ( i 1 1 ) ( i − 1 1 1 − i )
Eventually
P ( U ∪ D ) = P ( U ) + P ( D ) = 0 . 2 4 1 3 3
Problem Loading...
Note Loading...
Set Loading...
The man must either take one more step up than down or one more step down that up over the course of the 1 1 steps. So if we look at triplets of the form ( S , U , D ) for the number of steps staying put, going up or going down, respectively, the possibilities are
( 1 0 , 1 , 0 ) , ( 1 0 , 0 , 1 ) , ( 8 , 2 , 1 ) , ( 8 , 1 , 2 ) , ( 6 , 3 , 2 ) , ( 6 , 2 , 3 ) ,
( 4 , 4 , 3 ) , ( 4 , 3 , 4 ) , ( 2 , 5 , 4 ) , ( 2 , 4 , 5 ) , ( 0 , 5 , 6 ) , ( 0 , 6 , 5 ) .
We then need to consider all the permutations for each of these triplets and factor in the probabilities for each movement, (or lack of such). This gives us a probability of
k = 0 ∑ 5 ( 1 0 − 2 k ) ! ∗ k ! ∗ ( k + 1 ) ! 1 1 ! ∗ ( 0 . 1 ) 1 0 − 2 k ∗ ( ( 0 . 4 ) k + 1 ( 0 . 5 ) k + ( 0 . 4 ) k ( 0 . 5 ) k + 1 ) = 0 . 2 4 1
to 3 decimal places.