# Reference algorithm/formula for the distribution of the median of random variables?

The distribution of the mean of two random variables can be calculated using a convolution. I have a collection of $$n$$ independent random variables each with PDFs that are simple functions on $$[0,1]$$. I would like to know the exact distribution of the median of these variables. I understand there is a central limit theorem for the distribution of the sample median for i.i.d variables, but I don't have that assumption here. I also see that there's a way to get a formula for discrete random variables. Is there a reference for continuous random variables?

• The median is a particular order statistic, and there's a general formula here: en.wikipedia.org/wiki/… ... ah, but you don't have the iid assumption? (The link to the discrete case uses that assumption.) Mar 23 '21 at 16:03
• Are the variables independent, at least? Mar 23 '21 at 16:17
• @IgorRivin They are independent. Fixed. They are not identically distributed. Mar 23 '21 at 17:22

Assuming the number of your random variables is $$2n,$$ the probability that the median is $$x$$ equals $$m(x)=\sum_{\mbox{subsets I of size n}}\prod_{i \in I} F_i(x) \prod_{j\notin I}(1-F_i(x),$$ where $$F_k$$ is the CDF of the $$k$$-th variable. Needless to say, for $$n$$ large (as in, bigger than about 6), this is not super useful. If the variables are $$i.i.d,$$ this is a fairly civilized formula.