The problem is that an absent minded professor schedules two student appointments for the same time. The appointment durations are independent and exponentially distributed with mean thirty minutes. Both students arrive at the same time, what is the expected value of the time between the arrival of the first student and the departure of the second student?
This is my variation of the problem from https://www.youtube.com/watch?v=X5ch4xZf3LE&ab_channel=MITOpenCourseWare. The original problem has the second student arriving five minutes late.
I decided to redefine a simpler problem (as stated in the first paragraph) where the students arrive at the same time. I think the solution should be trivial, as the average is 30 min, we can expect the total time to be 60 min. However, I decided to solve this with the total expectation theorem based on the original solution to see if I would get 60 min. Unfortunately I do not and I am not sure why. My solution is as follows:
Let $T$ be the the time between the arrival of the first student and the second student. Let $T_1$ be the appointment duration of the first student and $T_2$ be the appointment duration of the second student.
From the total expectation theorem: $$ E[T] = P(T_1\leq t)E[T|T_1\leq t] + P(T_1 > t)E[T|T_1 > t]$$
Since $T_1$ and $T_2$ are exponentially distributed we have $P(T_1\leq t) = 1-e^{-\lambda t}$ and $P(T_1> t) = e^{-\lambda t}$
Next, by the definition of expectation we have $E[T|T_1\leq t] = E[T_1|T_1\leq t] + E[T_2|T_1\leq t] = \int_0^tx\lambda e^{-\lambda x} + 30 dx$
For the other scenario we have $E[T|T_1> t] = E[T_1|T_1> t] + E[T_2|T_1> t] = 5 + 30 + 30 = 65$, this is because of the memoryless property, given that $t$ minutes have passed for student 1's appointment it will take another 30 min to finish.
Finally, $$ E[T] = (1-e^{-\lambda t}) (\int_0^tx\lambda e^{-\lambda x} + 30) + (e^{-\lambda t})65$$
Here $\lambda=\frac{1}{30}$ and suppose that we use $t=5$. Plugging this in WolframAlpha results in $E[T]=59.68$.
So by complete accident, I took the integral out of the brackets and found that this equals $60$... But I have no idea why:
$$ E[T] = \int_0^tx\lambda e^{-\lambda x} + (1-e^{-\lambda t}) (30) + (e^{-\lambda t})65 = 60$$
Does anyone know why my solution does not produce 60 min, where am I making a mistake?
$\mathbb E[T_1 \mid T_1 \le t]$ is not equal to $\int_0^t x \lambda e^{-\lambda x}\,dx$.
The problem is that $\lambda e^{-\lambda x}$ is the PDF of $T_1$, not the PDF of $(T_1 \mid T_1 \le t)$. To find the PDF of $(T_1 \mid T_1 \le t)$ on $[0,t]$, we divide by $\Pr[T_1 \le t] = 1 - e^{-\lambda t}$. Then, we get $$ \mathbb E[T_1 \mid T_1 \le t] = \int_0^t x \cdot \frac{\lambda e^{-\lambda x}}{1 - e^{-\lambda t}} \,dx. $$