If you throw a dice 5 times, what is the expected value of the square of the median? My question: If you throw a dice 5 times, what is the expected value of the square of the median of the 5 results?
A slightly modified question would be: If you throw a dice 5 times, what is the expected value of the median? The answer would be 3.5 by symmetry.
For the square, it seems to be that symmetry does not hold anymore. Is there a "smart" way to solve this problem?
If there isn't a smart way to solve the problem, if there a smart way to estimate the answer?
 A: Let $X_1,\ldots, X_n$ be i.i.d. r.v. If we order the previous list of r.v. by it values we get r.v. $X_{(1)},\ldots ,X_{(n)}$ named the ranks of the list $X_1,\ldots,X_n$. Now, observe that the distribution of the $k$-th rank of $n$ i.i.d. r.v. is given by
$$
\Pr [X_{(k)}\leqslant c]=\Pr \left[\bigcup_{r\geqslant k}(\{X_{(j)}\leqslant c, j\leqslant r\}\cap \{X_{(j)}>c,j\geqslant r+1\})\right]\\
=\Pr \left[\bigcup_{r\geqslant k}\bigcup_{A\in \mathcal{A}_r}(\{X_j\leqslant c, j\in A\}\cap \{X_j>c,j\in A^\complement \})\right]\\
=\sum_{r\geqslant k}\binom{n}{r}F_{X_1}(c)^r(1-F_{X_1}(c))^{n-r}
$$
with the convention that $0^0:=1$ and where $\mathcal{A}_r:=\{B\subset \{1,\ldots,n\}: |B|=r\}$. Now observe that the median, $M$, of five i.i.d. r.v. is just $X_{(3)}$ and
$$
\mathrm{E}[M^2]=\sum_{k= 1}^6 k^2p_M(k)=\sum_{k=1}^{6}k^2(F_M(k)-F_M(k-1))
$$
Therefore, putting all together and using a CAS we get the result $\mathrm{E}[M^2]=\frac{2207}{162}\approx 13.62$.
A: This is small enough that it can be calculated explicitly through some code. Creating the matrix of throws is inefficient, but it should be clear to see how the universe of possibilities is spanned.
throws <- matrix(double(0), ncol = 5, nrow = 6^5)
throws[, 5] <- rep(1:6, each = 6^0, times = 6^4)
throws[, 4] <- rep(1:6, each = 6^1, times = 6^3)
throws[, 3] <- rep(1:6, each = 6^2, times = 6^2)
throws[, 2] <- rep(1:6, each = 6^3, times = 6^1)
throws[, 1] <- rep(1:6, each = 6^4, times = 6^0)
 
thrMed <- apply(throws, 1L, median) 
mean(thrMed)
[1] 3.5

mean(thrMed ^ 2)
[1] 13.62346

As stated in the comments, this is the expected squared median for five throws of dice. The symmetry no longer holds since $4^2 - 3.5^2 > 3.5^2 - 3^2$ and so on. Therefore the expected squared median is larger than the expected median squared.
