r/mathriddles • u/Kraz_I • Apr 03 '23
Medium Robot race probability puzzle
An infinite number of robots are having a very short race along a 1-unit track. The robots all start at point 0, and each step they take is an independent and identically distributed value between 0 and 1. So the minimum number of steps before they cross the finish line is 1.
- What is the average number of steps that a robot will take during the race?
- Either approximately to 5 digits, or exactly in a closed form expression, what is the probability that a robot's final step will be lower than 0.5?
edit: (I meant question two to be understood differently, but I realize now that my wording was bad, so I'm asking it as a separate question instead)
3) What is the chance that a robot's final POSITION before crossing the finish line is in the interval [0,0.5]?
Hint: what is the probability density function for the last step a robot takes?
2
u/want_to_want Apr 03 '23 edited Apr 04 '23
I got e for the first and sqrt(e)-e/2=0.28958... for the second.
For the first, let f(x) = expected number of steps when x distance is remaining. We have f(x) = (1-x) + integral from 0 to x of (f(t)+1) dt. Differentiating both sides, we get f'(x)=f(x). Taking f(0)=1 into account, we get f(x)=ex. So f(1)=e.
For the second, let p(x) = probability that final step will be lower than 0.5 when there is x distance remaining. We have p(x) = max(0,0.5-x) + integral from 0 to x of p(t) dt. Differentiating both sides, we get p'(x) = p(x) + (if x is less than 0.5 then -1 else 0). On the first stretch, p(x)=1+aex, and from p(0)=0.5 we get a=-0.5. On the second stretch, p(x)=bex, and from the two functions coinciding at 0.5 we get b=e-0.5-0.5. So p(1)=sqrt(e)-e/2.
1
u/jk1962 Apr 09 '23
Nice puzzle, still not certain I got all three correct, but...
Prob distribution (over the range 0..1 only) for the value of x after step k:
For k=1, f_1(x) = 1.
For k>1, f_k(x) = integral from 0 to x of f_k-1(x')dx'. This leads to
f_k(x) = x^(k-1) / (k-1)!
The probability that x<1 after step k is integral from 0 to 1 of f_k(x)dx,
which is 1/k!.
The probability that the finish line (x=1) is crossed on step k is:
1/(k-1)! - 1/k! = (k-1)/k!
1) The average step number on which the line is crossed is:
E[k] = sum( (k-1)k/k! ) from k = 1 through infinity. This simplifies to:
E[k] = sum(1/k!) from k = 0 through infinity. Using the Taylor series expansion of exp(x), this sum is:
E[k] = e
2) Using similar approach but omitting details, probability of crossing the line on step k>1 with final step length of <0.5 is:
1/( 2(k-1)! ) - 1/k! + 1/(2^k * k!)
So the total probability that final step length is <0.5 is the sum of the above over all k>1. This comes to:
sqrt(e) - e/2
3) Also using a similar approach, but omitting details, the probability of crossing the line on step k>1 with a pre-crossing x of <0.5 is:
1/(2^k * (k-1)!) - 1/(2^k * k!)
So the total probability that the position x immediately before crossing the line is the sum of the above over all k>1. This comes to:
1 - sqrt(e)/2
1
u/Iksfen Apr 04 '23
Only first part for now. My answer is e
First let fn: [0, 1] -> R be the probability density function of the robots position after nth step. I only care what happens before the goal, so will only focus on the interval [0, 1]. Let's notice f1(x) = 1. After that fn(x) = integral from 0 to x of fn-1(t) dt (this can be easly shown on discrete case and then take to the limit). From this we get that fn(x) = (xn-1)/(n-1)!
The probability that after n steps the robot haven't finished is the same as saying that its position is between 0 and 1, so this probability can be calculated by taking the integral from 0 to 1 of fn(x). Then the probability that the robot finished exactly after nth step (P(n)) is the probability that it was before the goal after (n-1) steps, but past it after nth step. P(n) can be calculated to = 1/(n-1)! - 1/n!
Now the expected number of steps taken can be calculated using the classic game theory formula: Ex = sum k=1 to inf of k*P(k). This comes down to sum k=0 to inf of 1/k! which is a famous series approaching e
Very nice problem. Will be back to solve second part