I've been working through past MIT Primes problems, and got stuck on 2021 Problem M4:
A particle is initially on the number line at a position of $0$. Every second, if it is at position $x$, it chooses a real number $t \in [−1, 1]$ uniformly and at random, and moves from $x$ to $x+t$. Find the expected value of the number of seconds it takes for the particle to exit the interval $(−1, 1)$.
I've been trying to solve it differently from the solution they provided. Let me outline my approach.
Let $X$ denote the number of seconds it takes the particle to exit $[-1, 1]$. Then, we are looking for
$$ \text{E}[X] = \sum_x x \Pr(X=x) $$
The PMF of $X$ is
$$ \Pr(X = x) = \Big( 1 - \Pr(-1 < X_x < 1) \Big) \prod_{i=1}^{x-1} \Pr(-1 < X_i < 1) $$
where $X_t$ is $X$ at time $t$. We have now punted the problem to finding $\Pr(-1 < X_i < 1)$ for all $i$. Remember, each $X_i$ is dependent on $X_{i-1}$. We can make a step towards finding $\Pr(-1 < X_i < 1)$ using the law of total probability:
$$ \Pr(X_i \leq x) = \int_{-\infty}^\infty \Pr(X_i \leq x \mid X_{i-1}=y) f_{X_{i-1}}(y) \ \text{d}y $$
$\Pr(X_i \leq x \mid X_{i-1}=y)$ can be defined as a piecewise function (I derived this by fixing $y$, and then considering $x$):
$$ \Pr(X_i \leq x \mid X_{i-1}=y) = \begin{cases} \frac{x+1}{2+y} & -1 \leq y < 0 \; \land \; x \leq y + 1 \\ 1 & -1 \leq y < 0 \; \land \; x > y + 1 \\ \frac{x-y+1}{2-y} & 0 \leq y < 1 \; \land \; x \geq y - 1 \\ 0 & 0 \leq y < 1 \; \land \; x < y - 1 \end{cases} $$
We also know that $f_{X_{i-1}}(y)$ is the derivative of $\Pr(X_{i-1} \leq y)$. Because $\Pr(X_1 \leq x) = (x + 1)/2$, we can now find $\Pr(X_2 \leq x)$.
Now here is the problem. I evaluated $\Pr(X_2 \leq x)$ using the following Mathematica script:
(* the piecewise function *)
XiCDFconditional[x_, y_] = Piecewise[{
{(x + 1) / (2 + y), -1 <= y < 0 && x <= y + 1},
{1, -1 <= y < 0 && x > y + 1},
{(x - y + 1) / (2 - y), 0 <= y < 1 && x >= y - 1},
{0, 0 <= y < 1 && x < y - 1}
}];
X1CDF[x_] = (x + 1) / 2;
(* Pr(X2 <= x) *)
X2CDF[x_] = Integrate[XiCDFconditional[x, y] * X1CDF'[y], {y, -Infinity, Infinity}]
when I execute X2CDF[1] - X2CDF[-1] (i.e. $\Pr(-1 \leq X_2 \leq 1)$), I get $1$, which is obviously incorrect. Where did I screw up?
I feel like I might have subtly screwed up $\Pr(X_i \leq x \mid X_{i-1}=y)$. Or maybe I didn't screw up, and I'm almost surely (pun intended) getting confused in the continuous world.
As discussed in the comments, this approach isn't going to work as it stands, because the positions at different times aren't independent. But just to answer the original question: because the jumps $(t\in[-1,1])$ are chosen uniformly, and in particular don't depend on the initial position, you must have $\Pr(X_i \leq x \mid X_{i-1}=y)=g(x-y)$ for some $g$. (In other words, only the distance from the old position to the new one can matter.) And pretty clearly this should be $$ \Pr(X_i \leq x \mid X_{i-1}=y) = \begin{cases} 0 \qquad &\text{if }& x-y<-1; \\ \frac{1}{2}(x-y+1) \qquad &\text{if }& x-y \in [-1,1]; \\ 1 \qquad &\text{if }& x-y>1. \end{cases} $$ If you fix $y$ and take the derivative with respect to $x$, then this gives you the expected and properly normalized probability distribution for the position after a random jump starting at $y$: zero outside the interval $[y-1,y+1]$, and uniformly equal to $1/2$ inside it.