An expected value puzzle

266 Views Asked by At

While working on a larger problem, I encountered this smaller problem that I’ve enjoyed thinking about, but have yet to solve.

Shuffle the numbers 0 to 24 into a 5 by 5 matrix. Sort each column in ascending order, then sort each row in ascending order. What’s the expected value of the $(i, j)$ entry?

1

There are 1 best solutions below

0
On

Since we're working with numbers starting from $0$, we'll use indices starting at $0$ as well, i.e. position $(0,0)$ is the first and $(4,4)$ the last.

Call $X(i, j)$ the variable for the position $(i, j)$. It's not difficult to figure out* that because of symmetry we have the relation $E[X(i, j)]+E[X(4-i, 4-j)]=24$, which cuts the workload in half and tells us right away that $E[2, 2]=12$, apart from the obvious $E[0, 0]=0$ and $E[4, 4]=24$

Knowing this, it's only a matter of tedious and boring work to figure out the exact expected value at each position, and I've not found any shortcuts. It is way easier, given a position, to figure out which values can end up there and list the possible final (i.e. after sorting) configurations, calculating their probability.

For the first row: given position $(0, j)$ with $1\le j\le4$, the possible values that after sorting can end up in this position range from $j$ to $5j$, and the probability that $x$ in this range will be sorted in this position is equal to the probability that all values from $j$ to $x-1$ will be sorted into exactly $j-1$ columns, with $x$ not being in those same columns.

*To be precise, if at position $(i, j)$ we have values $a_1, ...,a_k$ with respective probabilities $p_1, ...,p_k$, then at position $(4-i, 4-j)$ we will have values $24-a_1, ...,24-a_k$ with the same respective probabilities.