Statistics Math Problem

JBCM627

Veteran
Joined
Apr 27, 2008
Messages
799
Location
Ohio, USA
WCA ID
2006MERT01
An interesting little math problem from a physics class.


Two people start out at the origin, both having the same probability of taking a step to the left or a step to the right along the x axis. Find the probability that they end up at the same spot after having taken N steps.


To be clear, the step sizes are always the same. The people will not hit each other. They make steps at the exact same time. Etc.

Hint: consider the relative motion of the people.
Bonus for Lucas: Same thing with 2 people scrambling a Sq-1.
 
Last edited:
(.5)n?

definitely a guess. But now that I'm reading the hint I'd guess it's incorrect.

I'm not sure how else to approach this problem though, someone with a much better statistics background than me will certainly be able to explain it well.
 
A good check for this is to see what happens as n -> Infinity. The chance of them landing on the same spot should go to 0.

This brings up a good point though; I don't mean to ask what the cumulative probability of them having landed on a spot is; rather what is the probability they will end up at the same spot. Edited my initial post to clarify...
 
Here's what I'd do:
Label one person 1 and the other 2. Then define the variable d as the value of the x-coordinate of person 2 minus the x-coordinate of person 1, divided by 2. We can see that on each step we add the following to d: either -1 (with 1/4 probability), 1 (with 1/4 probability), or 0 (with 1/2 probability, since both people are going in the same direction). This is equivalent to first adding -1 to d and then, twice, adding either 0 or 1 with 1/2 probability each.

Anyway we want to know the probability that d = 0 after n steps. Because of our alternate calculation method this is equivalent to the probability that, if we add 2n "0 or 1 with 1/2 probability each" random variables together, and then subtract n, we will get 0, which can further be thought of as the probability that after 2n coin flips we get n heads. The expression for this is easy to write:
(2n choose n)/(2^(2n)).
 
This will be hard for me because I have just started university so I didn't study anything about statistics...

Mmm, ok, let's see:

If I am thinking correctly the probability may be:
1 step: 2*1/2^2 = 50%
2 steps: 2*1/4^2 + 2/4^2 = 37.5%
3 steps: 2*1/8^2 + 2*3/8^2 = 31.25%
4 steps: 2*1/16^2 + 2*4/16^2 + 6/16^2 = (1+16+36+16+1)/256= 27.34%
5 steps: (1+25+100+100+25+1)/1024 = 24.61%
6 steps: (1+36+225+400+255+36+1)/4096 = 22.56%

N steps: (something with the sum of N+1 squared numbers which sum (not squared) is equal to 2^N) / (2^(2N))
 
Last edited:
For them to be at the same position at the end they need to take equal number of steps in a certain direction say 'x' (since both of them take equal number of steps) .The probability is (N Choose x) x^0.5 (N-x)^0.5p
Without knowing the value of x or the final position how can one find the probability? Or is the final position the origin itself?
Where am I going wrong?
 
I had to do some illustration to figure this one out, but I am pretty sure that I have it.

Using a basic number line, I determined what possible locations our subjects could end up on after n steps.

-5 -4 -3 -2 -1 0 1 2 3 4 5
I went through n=1 to 5 to get this one. It turns out that the number of possible locations is n+1

To determine the total number of possible outcomes, you have to square the number of possible locations: (n+1)^2

For the probability, you then have (n+1)/(n+1)^2

Correct?
 
Carson, that can't be correct. Explanation in the spoiler below:

You are assuming that all positions are equally likely, which isn't the case. For n=6, Position 0 is far more likely than position 6. Much like getting 3 tails and 3 heads compared to getting 6 heads in a row.

My solution:
Using a recursive algorithm, the following values can be found:
  1. 0.5
  2. 0.375
  3. 0.3125
  4. 0.2734375
  5. 0.24609375
  6. 0.2255859375
  7. 0.20947265625
  8. 0.196380615234375
  9. 0.185470581054688
  10. 0.176197052001953

Of course using a recursive algorithm isn't in the spirit of the challenge but having the answers in front of you does help. I found a solution using the binomial distribution.

We do not need to bother with the absolute positions, we only need to consider the relative positions. This gives us the following distribution:

ll: 0
rr: 0
rl: -2
lf: +2

For S steps, there can be 0 to S "neutral" moves. The probability for N neutral moves is BinomPDF(n=S, p=0.5, k=N). Next, there need to be as many -2 moves as +2 moves. For an odd N, this probability is 0. For an even N, it is BinomPDF(n=S-N, p=0.5, k=(S-N)/2)

To find to probability for S steps we simply need to sum the probabilities we found above. In pseudocode:

Code:
p = 0;
for(n=0; n++; n<=s){
 if(IsInt((s-n)/2)){
  p = p + BinomPDF(s, 0.5, n) * BinomPDF(s-n, 0.5, (s-n)/2);
 }
}

This gives the exact same results as the recursive algorithm:
  1. 0.5
  2. 0.375
  3. 0.3125
  4. 0.2734375
  5. 0.24609375
  6. 0.2255859375
  7. 0.20947265625
  8. 0.196380615234375
  9. 0.185470581054688
  10. 0.176197052001953

I think a more elegant solution should exist, and I'm not really satisfied with mine.

qqwref, I think you've got it wrong. For n=0 you get p=2 and for n=3 you get p=0.125 which isn't correct according to my hand-verification.
 
Carson, that can't be correct. Explanation in the spoiler below:

You are assuming that all positions are equally likely, which isn't the case. For n=6, Position 0 is far more likely than position 6. Much like getting 3 tails and 3 heads compared to getting 6 heads in a row.

My solution:
Using a recursive algorithm, the following values can be found:
  1. 0.5
  2. 0.375
  3. 0.3125
  4. 0.2734375
  5. 0.24609375
  6. 0.2255859375
  7. 0.20947265625
  8. 0.196380615234375
  9. 0.185470581054688
  10. 0.176197052001953

Of course using a recursive algorithm isn't in the spirit of the challenge but having the answers in front of you does help. I found a solution using the binomial distribution.

We do not need to bother with the absolute positions, we only need to consider the relative positions. This gives us the following distribution:

ll: 0
rr: 0
rl: -2
lf: +2

For S steps, there can be 0 to S "neutral" moves. The probability for N neutral moves is BinomPDF(n=S, p=0.5, k=N). Next, there need to be as many -2 moves as +2 moves. For an odd N, this probability is 0. For an even N, it is BinomPDF(n=S-N, p=0.5, k=(S-N)/2)

To find to probability for S steps we simply need to sum the probabilities we found above. In pseudocode:

Code:
p = 0;
for(n=0; n++; n<=s){
 if(IsInt((s-n)/2)){
  p = p + BinomPDF(s, 0.5, n) * BinomPDF(s-n, 0.5, (s-n)/2);
 }
}

This gives the exact same results as the recursive algorithm:
  1. 0.5
  2. 0.375
  3. 0.3125
  4. 0.2734375
  5. 0.24609375
  6. 0.2255859375
  7. 0.20947265625
  8. 0.196380615234375
  9. 0.185470581054688
  10. 0.176197052001953

I think a more elegant solution should exist, and I'm not really satisfied with mine.

qqwref, I think you've got it wrong. For n=0 you get p=2 and for n=3 you get p=0.125 which isn't correct according to my hand-verification.

Wow, so my solution is right:

This will be hard for me because I have just started university so I didn't study anything about statistics...

Mmm, ok, let's see:

If I am thinking correctly the probability may be:
1 step: 2*1/2^2 = 50%
2 steps: 2*1/4^2 + 2/4^2 = 37.5%
3 steps: 2*1/8^2 + 2*3/8^2 = 31.25%
4 steps: 2*1/16^2 + 2*4/16^2 + 6/16^2 = (1+16+36+16+1)/256= 27.34%
5 steps: (1+25+100+100+25+1)/1024 = 24.61%
6 steps: (1+36+225+400+255+36+1)/4096 = 22.56%

N steps: (something with the sum of N+1 squared numbers which sum (not squared) is equal to 2^N) / (2^(2N))

What I did was to count of different ways to be at each spot with each step:

starting from 0 steps:

1
1-1
1-2-1
1-3-3-1
1-4-6-4-1
1-5-10-10-5-1
1-6-15-20-15-6-1
1-7-21-35-35-21-7-1
....
where each number of the new row is: (for example for row 6: x[6,i]= x[5,(i-1)]+ x[5,i]
 
Because of our alternate calculation method this is equivalent to the probability that, if we add 2n "0 or 1 with 1/2 probability each" random variables together, and then subtract n, we will get 0, which can further be thought of as the probability that after 2n coin flips we get n heads. The expression for this is easy to write:
(2n choose n)/(2^(2n)).
Good reasoning til here.

This is a Markov Chain if I remember right. I learned this last year, but I forgot now the formula :). The probability is nethier 0 nor 0.5. I can check the old course papers for the formula if you really want.
This does work, but is quite impractical for large n. I think it would be necessary for the Sq-1 bonus, though...

My solution:
...
The values you have are correct, along with the work. You are also correct about another solution existing though, so the challenge still stands :) I was looking for the chance they meet as a pure function of the number of steps. The final equation should have no recursion, no summations over the probability they will meet at n using dummy variables, etc.
 
Last edited:
I have found a direct approximation:
This can be solved using the normal distribution. For the relative distance D between person A and B:

Code:
A B D
l r +1 (25%)
r l -1 (25%)
l l 0  (25%)
r r 0  (25%)

The expected value of D (for one step) is 0 (0.25*-1 + 0.25*1 + 0.25*0 + 0.25*0). The variance (for one step) is 0.5 (0.25*1^2+0.25*(-1)^2).

For N steps, E(D)=0*N=0 and Var(D)=Var(1)*N.

While the normal distribution isn't intended for discrete problems, it can still be used as an approximation. -0.5 and 0.5 are used as bounds.

This gives us P(D=0) = NormalCDF(-0.5, 0.5, 0, sqrt(0.5*N)).

Accuracy increases with N, but even for N=1 this is fairly accurate.:

  1. 0.52050
  2. 0.38292
  3. 0.31691
  4. 0.27633
  5. 0.24817
  6. 0.22717
  7. 0.21073
  8. 0.19741
  9. 0.18634
  10. 0.17694

I'm working on the "really nice" solution.

Edit: I have found the "really nice" solution.
I could not explain it for the life of me but after I noticed Pascal's triangle in Lucas's solution I "got it". Using wolfram alpha I found a way of expressing the relevant numbers in a direct formula. The mangled result:

Edit2: but maybe a nicer solution exists...
 
Last edited:
Edit: I have found the "really nice" solution.
I could not explain it for the life of me but after I noticed Pascal's triangle in Lucas's solution I "got it". Using wolfram alpha I found a way of expressing the relevant numbers in a direct formula. The mangled result:

Edit2: but maybe a nicer solution exists...

Close, but you have an off-by-one error. Still, nice work.
Sub in (n+1) for n, use the rule (2n-1)!! = (2n)!/(n!*2^n) and you get this (Warning: answer).
 
Wow... how did I fail to notice that?

I really like the solution using the normal distribution... While it is not the 'perfect' solution I like it in its simplicity.
 
Last edited:
Wow, I didn't even know that what I was building to solve it was "the pascal triangle".
 
Back
Top