Suppose we have ordered numbers $a_1 < a_2 < \dots < a_n$. Now we sample $k$ of them with equal probability and with replacement and compute the median of these and call it $m$. (Let us assume that $k$ is odd for the sake of simplicity.) What is the probability the $m = a_i$ for each $i$?
I want to know this to construct the probability mass function for the median of $k$ random draws from a sample of $n$ numbers.
If $m$ is the median of $k$ samples, and $u$ is the number of samples $\le m$, then
$$P(m \le a_i) = \frac{1}{n^k}\sum_{u=(k+1)/2}^k \binom{k}{u}\, i^u\, (n-i)^{k-u}$$ $$P(m = a_i) = P(m \le a_i) - P(m \le a_{i-1})$$
$$\ $$ A good test case is $n=4, i=2, k=3$ for which we can list the relevant cases.
The median is 1 if the samples are the
for a total probability of 10/64, which agrees with the formula.
The median is 2 if the samples are the
for a total probability of 22/64, which also agrees with the formula.