# Sample median of sample from uniform distribution.

I'm trying to determine the distribution of the sample median of a sample of size $n$ from the uniform distribution (on the interval $(0,1)$). If $n$ is odd and $m=(n+1)/2$, then the sample median is just one of the order statistics and it has a beta distribution whose both parameters are $m$. But I am having some problems finding its distribution when the size of the sample is even.

I proceeded in the obvious way: given a sample from a population with density $f$ and distribution $F$, the joint distribution of the order statistics $(X_{(j)},X_{(k)})$, $1\leq j<k\leq n$ is $$f_{X_{(j)},X_{(k)}}(x,y)=\frac{n!}{(j-1)!(k-j-1)!(n-k)!}[F(x)]^{j-1}[F(y)-F(x)]^{k-1-j}[1-F(y)]^{n-k}f(x)f(y),$$ where $x<y$. If $m=n/2$, the sample median is given by $(X_{(m)},X_{(m+1)})/2$, and using the above formula, the density of the sample median must be given by $$g(z)=2\int_{-\infty}^{\infty}f_{X_{(m)},X_{(m+1)}}(2z-x,x)dx\\ =\frac{2n!}{(m-1)!^2}\int_{-\infty}^{\infty}(2z-x)^{m-1}(1-x)^{m-1}1_{(0,1)}(2z-x)1_{(0,1)}(x)1_{(0,x)}(2z-x)dx$$ And, after some simplifications, I arrive to the following formula $$g(z)=\frac{2n!}{m(m-1)!^2}\Big(\frac{(1-z)^m}{2z-1}(z^m-(1-z)^m)\\-\frac{(1-\min{(1,2z)})^m}{2z-1}((2z-\min{(1,2z)})^m-(1-\min{(1,2z)})^m)\Big)1_{(0,1)}(z)$$ But for $n=4$ this function integrates to 5, which clearly is not possible.

I have checked this procedure twice and I keep getting the same formula. In my computations, I found that $1_{(0,1)}(2z-x)1_{(0,1)}(x)1_{(0,x)}(2z-x)=1_{(0,1)}(z)1_{(z,\min{(1,2z)})}(x)$ and I think this may be where I'm wrong, since everything else is just standard integration.

Thanks for any any help in advance.

• As shown here, for $n=4$, density of sample median takes the form $g(z)\propto \int_{z}^{\min(2z,1)}(2z-v)(1-v)\,dv$ whenever $0<z<1$. The complete pdf can be written as $$g(z)=8z^2(3-4z)\mathbf1_{0<z<1/2}+8(z-1)^2(4z-1)\mathbf1_{1/2<z<1}$$ Jun 2 '20 at 19:25