# A Short Probability Problem

Table of Contents

The problem

Given a1 ~ Unif(0,1), a2 ~ Unif(0,2), a3 ~ Unif(0,3), a4 ~ Unif(0,4) and a5 ~ Unif(0,5), what is P(a1 <= a2 <= a3 <= a4 <= a5)?

I recently saw this problem in an instagram reel, and after some help from a friend (thanks zhi!) and an hour plus of struggling with it, I finally (roughly) understand how to approach this!

Note: I am extremely unfamiliar with math in general and therefore some things were extremely foreign to me

Mistakes

I have solved a similar problem (janestreet dec 2025, writeup coming!) before where we had to calculate something like P(a1 <= a2).
One way to approach this is geometrically (groan).

Graph of a2/a1

As you can see, the square represents the space of all possible combinations of (a1,a2).
Therefore, if we want to find the probability that a1<=a2, we can simply take the area where a1<=a2/total area.
With this in mind, P(a1a2)=(1/211)/11=0.5P(a1 \leq a2) = (1/2 * 1 * 1) / 1*1 = 0.5

Therefore, a natural follow up to having more a_x would to this thinking into a higher-dimensional space.
This 5D space would have volume 1x2x3x4x5 = 120 (a1 x a2 x a3 x a4 x a5)
Then, we should ask ourselves what hyper-volume of this space represents the set of (a1,a2,a3,a4,a5) where a1 <= a2 <= a3 <= a4 <= a5?

PS: it is probably not important to read past here if you are merely trying to understand the solution. This is more of a “for myself” section.

As a professionally terrible at geometry enjoyer, I was already getting lost here. No matter, chatgpt to the rescue!

Now, ChatGPT 5.2 thinking suggested that I start from a1 and integrate my way up to a5. Sounds reasonable.
Therefore, let v1(u)v_1(u) be the length of the 1D volume of choices for a1 given a2=ua2 = u.
Therefore, vn(u)v_n(u) would be the volume of the N-D volume of choices for (a1,a2,...,an)(a_1, a_2, ... , a_n) given that an=ua_n = u

To find the resultant volume, we would simply evaluate 05v4(u)du\int_0^5{v_4(u)}{du}.

Let us now try this.
Given a2=ua_2=u, a1a_1 can exist in the interval [0, min(1,u)].
Therefore, v1(u)=0min(1,u)1du=min(1,u)v_1(u) = \int_0^{min(1,u)}{1}\,{du} = min(1,u)

and then, given that a3=ua3 = u v2(u)=0min(2,u)v1(t)dtv_2(u) = \int_0^{min(2,u)}{v_1(t)}\,dt

To compute this integral, we would now have to split between the cases where 0u10 \leq u \leq 1, 1u21 \leq u \leq 2, 2u32 \leq u \leq 3 and then for each of these cases, there are subcases for the ranges of t as well.

This quickly becomes a mess of piecewise functions and feels terrible to calculate. There has to be a better way!

The better way

Previously, we attempted to integrate from the bottom up, starting with a1 and working our way up to a5.
The problem we faced was that each function was dependent on the functions before it, and therefore dependent on the bounds of each random variable before it.
This “stacking” of piecewise functions caused an explosion in the number of terms we had to evaluate, as we had to “update” the “state” of each integral with the potential states of past integrals.

What if we try to integrate from the bottom down instead? If we start by integrating from a5a_5, which only depends on a4a_4 (as a4a_4 implicitly “encodes” the information of a3,a2,a1a_3, a_2, a_1, we might not need to deal with this issue)

Our goal still satyas the same, to have a 5D space which volume represents the set of all (a1,a2,a3,a4,a5)(a_1,a_2,a_3,a_4,a_5), and to find the hyper-volume of the space which represents the set of (a1,a2,a3,a4,a5)(a_1,a_2,a_3,a_4,a_5) where a1a2a3a4a5a_1 \leq a_2\leq a_3 \leq a_4\leq a_5.

Let us start with a5a_5.
The “length” of values that a5a_5 can take is 5a45 - a_4.
This is because 0a550 \leq a_5 \leq 5 and a4a5a_4 \leq a_5.
The alternative way to think about this is that the 1-D volume that a5a_5 can take is given by the integral

V(a5)=a451da4=5a4\begin{aligned} &V(a_5) = \int_{a_4}^{5}{1}\,da_4 = 5 - a_4 \end{aligned}

Therefore, the 2-D volume that is given by the set of valid (a5,a4)(a_5,a_4) values is

V(a5,a4)=a345a4da3=125a3+12a32\begin{aligned} &V(a_5,a_4) = \int_{a_3}^{4}{5 - a_4}\,da_3 = 12 - 5a_3 + \frac{1}{2}{a_3}^2 \end{aligned}

This is because 0a440 \leq a_4 \leq 4 and a3a4a_3 \leq a_4.
Therefore, by integrating the length of a5a_5 over the values of a4a_4, we can find the area.
Here is the key observation. We can say that the values of ana_n solely depend on the value of an1a_{n-1}! This is due to the fact that for an1a_{n-1} to exist in the set of valid solutions, the previous criteria for a1,a2,a3a_1,a_2,a_3 have already been fulfilled.

Next, we find the 3-D volume that is given by the set of valid (a5,a4,a3)(a_5,a_4,a_3) values, with the same set of reasoning as before

V(a5,a4,a3)=a23125a3+12a32da2=...=1812a2+52a2216a23\begin{aligned} &V(a_5,a_4,a_3) = \int_{a_2}^{3}{12 - 5a_3 + \frac{1}{2}{a_3}^2}\,da_2 = ... = 18 - 12a_2 + \frac{5}{2}{a_2}^2 - \frac{1}{6}{a_2}^3 \end{aligned}

Now, for the 4-D volume that is given by the set of valid (a5,a4,a3,a2)(a_5,a_4,a_3,a_2) values, with the same set of reasoning as before

V(a5,a4,a3,a2)=a121812a2+52a2216a23da1=...=1818a1+6a1256a13+124a14\begin{aligned} &V(a_5,a_4,a_3,a_2) = \int_{a_1}^{2}{18 - 12a_2 + \frac{5}{2}{a_2}^2 - \frac{1}{6}{a_2}^3}\,da_1 = ... = 18 - 18a_1 + 6{a_1}^2 - \frac{5}{6}{a_1}^3 + \frac{1}{24}{a_1}^4 \end{aligned}

And finally, for the 5-D volume that is given by the set of valid (a5,a4,a3,a2,a1)(a_5,a_4,a_3,a_2,a_1) values

V(a5,a4,a3,a2,a1)=101818a1+6a1256a13+124a14da1=189+2524+1120=545\begin{aligned} &V(a_5,a_4,a_3,a_2,a_1) = \int_{1}^{0}{18 - 18a_1 + 6{a_1}^2 - \frac{5}{6}{a_1}^3 + \frac{1}{24}{a_1}^4}\,da_1 = 18 - 9 + 2 - \frac{5}{24} + \frac{1}{120} = \frac{54}{5} \end{aligned}

And to arrive at the final answer,

P(a5a4a3a2a1)=545120=9100=0.09=9%\begin{aligned} &P(a_5\geq a_4\geq a_3\geq a_2\geq a_1) = \frac{\frac{54}{5}}{120} = \frac{9}{100} = 0.09 = 9\% \end{aligned}

There you have it! Hopefully this was helpful and interesting :D

My avatar

Hopefully this was an interesting read! Feel free to check out my other posts or contact me via the social links in the footer.


More Posts