# Continuous random variables - probability of a kid arriving on time for school

A father leaves his home to take his son to school between 6:15 AM and 6:45 AM and it usually takes between 30 and 40 minutes to arrive there. Let $$X$$ and $$Y$$ be independent and random uniformly distributed continuous variables that stand for, respectively, the time of departure from home and the time spent on the way to school. What is the probability that the kid will arrive before class begins, at 7 AM?

(I'm sorry if something is misspelled or in an unusual order. I'm not a native speaker so I'm not sure if the order on "random uniformly distributed continuous variables" is correct)

I frankly have very little idea regarding how to proceed here. The first thing I'd thought about doing is converting the times to only minutes, in such a way as to make $$X$$ and $$Y$$ comparable (in a sense). After that, imagining 7 AM as 420 minutes, we'd need to have $$X+Y < 420$$. After this, I'm stuck (I'm not even sure the reasoning prior to this is solid).

Any help is highly appreciated!

• I love "probability of a kid arriving on time for school" as an example for a random variable. It is ;-). – Peter - Reinstate Monica May 4 at 15:21
• @Peter-ReinstateMonica for me, at least, it really was! :D – Pedro Cunha May 4 at 15:47
• Where the hell do classes start at 7:00 AM?!? – VARulle May 26 at 9:21
• It's very common in Brazil, @VARulle ! – Pedro Cunha May 27 at 17:25

As you suggested, $$X$$ and $$Y$$ can be described as two independent uniform random variables $$X \sim \mathcal{U(375, 405)}$$, $$Y \sim \mathcal{U(30, 40)}$$. We are interesting in finding $$\mathbb{P}[X + Y \leq 420]$$. This problem can be handled with a straightforward geometric approach.

$$\mathbb{P}[X + Y \leq 420] = \frac{\text{grey area}}{\text{total area}} = \frac{ \Delta y \times d_1+ \frac{1}{2}\Delta y \times d_2}{\Delta x \times \Delta y} = \frac{5 + \frac{1}{2}\cdot10}{30} = \frac{1}{3},$$ where $$\Delta x = 405 - 375 = 30$$, $$\Delta y = 40 - 30 = 10$$, $$d_1 = (420-40)-375$$ and $$d_2 = 390 - (420-40)$$

• I marked your answer because it was the one with a simpler approach. Thanks! edit: what program did you use to make that figure? – Pedro Cunha May 2 at 23:28
• In Python 3 with Matplotlib library and using in particular the function pyplot.fill. – nonin May 3 at 7:31

Write $$X \sim U(15,45)$$ and $$Y \sim U(30,40)$$, then can write what you are trying to solve for as $$P(X+Y<60)$$. I am using the starting time here as 6:00AM and therefore need the sum of time passed until departure and drive time to be less than 60.

Define $$Z=X+Y,$$ so that $$F_Z(z) = \int_{30}^{40} F_X(z-y)f_Y(y)dy,$$ which follows from summing two independent continuous random variables. We would like to solve for $$F_Z(60)$$. Replacing $$z=60, F_X(x)=\frac{x-15}{30},$$ and $$f_Y(y) = \frac{1}{10}$$, we have

$$P(\text{Arrive before 7AM}) = \int_{30}^{40} \frac{(60-y)-15}{30}\frac{1}{10}dy$$ $$P(\text{Arrive before 7AM})= \frac{1}{300} \int_{30}^{40} (45-y)dy=\frac{1}{3}.$$

A simpler approach:

There's a 30-minute interval during which he can leave, thus there's a $$x/30$$ chance of leaving during any given $$x$$-minute period.

• There's a $$5/30$$ chance of leaving between 6:15 and 6:20, and there'll be a $$100\%$$ chance of arriving before 7 if he leaves at any point during that interval.
• There's a $$10/30$$ chance of leaving between 6:20 and 6:30.

At 6:20 there's a $$100\%$$ chance of arriving before 7.

At 6:30 there's a $$0\%$$ chance of arriving before 7 (since time is continuous, there's a $$0\%$$ chance of taking exactly 30 minutes).

The chance of arriving before 7 decreases linearly between 6:20 and 6:30, because this simply corresponds to (the reverse of) the probability of having the duration of the journey be shorter than some duration, which is linear.

We can average these percentages and say there's a $$50\%$$ chance of arriving before 7 if we leave at some random point between 6:20 and 6:30.

• There's a $$0\%$$ chance of arriving before 7 if we leave after 6:30, so we can disregard this.

Now we can simply add up the probabilities to get the overall probability:

$$5/30 * 100\% + 10/30 * 50\% + 0 = 5/30 + 5/30 = 10/30 = 1/3$$

So there's a $$1/3$$ chance of arriving before 7 AM.

We should begin by partitioning the space.

If the dad leaves at 6:45, then there is a 0% chance he makes it to school on time since the ride takes in the shortest case 30 mins. So at the very latest, the dad needs to leave between 6:15 and 6:30.

Let's write out some scenarios:

• Dad leaves 0 minutes after 6:15, he can take at most 45 minutes

• Dad leaves 5 minutes after 6:15, he can take at most 40 minutes

• Dad leaves 10 minutes after 6:15, he can take at most 35 minutes

• Dad leaves 15 minutes after 6:15, he can take at most 30 minutes

• Dad leaves any later than that, the kid will be late

Let $$X \sim U(0,30)$$ be the minutes dad leaves after 6:15 and let $$Y\sim U(30,40)$$ be the duration of the ride in minutes. The kid will arrive on time if

$$X+Y \leq 45$$

An alternative way to think about this is "the time for the kid to get to school, including the time for dad to leave, must not exceed 45 minutes assuming the dad leaves at 6:15 at the earliest". Because both random variables are uniform, you can just take the ratio of areas to compute probability.

The area of the space where dad can make it to school is 5*10 + 10*10/2 = 100. The area of the entire space is 300. So there is a 1/3 chance dad makes it. Let's verify this with simulation.

x = runif(100000000,0, 30)
y = runif(100000000,30,40)

mean(x+y<45)
>>>0.3333499


Which is correct to within simulation error.