Why the median p.d.f. of the uniform distribution is not a p.d.f

density functionorder-statisticsprobabilityprobability distributions

Let $X$ be uniformly distributed on interval $[\theta-2, \theta+2]$, $\theta\in\mathbb{R}$. Let the sample size of $3$, find the p.d.f. of median!

I have tried as follows.

The p.d.f. of $X$ is
\begin{align}
f_X(x)=
\begin{cases}
\dfrac{1}{4}&x\in[\theta-2, \theta+2]\\
0&\text{otherwise}
\end{cases}.
\end{align}

The c.d.f. of $X$ is
\begin{align}
F_X(x)=
\begin{cases}
0&x<\theta-2\\
\dfrac{1}{4}x&x\in[\theta-2, \theta+2]\\
1&x>\theta+2
\end{cases}.
\end{align}

Let the order statistics: $Y_1\leq Y_2\leq Y_3$, then the median is $Y_2$.

Now I use the formula for determining the p.d.f. of median.

\begin{align}
g(y_2)&=\dfrac{3!}{(2-1)!(3-2)!}\left(\dfrac{1}{4}y_2\right)^{2-1}\left(1-\dfrac{1}{4}y_2\right)^{3-2}\dfrac{1}{4}\\
&=\dfrac{3}{8}y_2\left(1-\dfrac{1}{4}y_2\right)
\end{align}

for $y_2\in[\theta-2,\theta+2]$ and $0$ otherwise.

Now I want to check $g(y_2)$ is p.d.f. using maple.

enter image description here

We have the value of

$$\int\limits_{\theta-2}^{\theta+2} \dfrac{3}{8}y_2\left(1-\dfrac{1}{4}y_2\right) dy_2=-\dfrac{1}{32}(\theta+2)^3+\dfrac{1}{32}(\theta-2)^3+\dfrac{3}{16}(\theta+2)^2-\dfrac{3}{16}(\theta-2)^2.$$

If I try to substituting $\theta=2$ then the rhs of integral is $1$. In other hand,
if I try to substituting $\theta=5$ then the rhs of integral is $-\dfrac{19}{8}$. So generally for any $\theta\neq 2\in\mathbb{R}$, I can conclude this is not probability density function.

Why this can happen, even though I use the correct formula for finding the p.d.f. of median?

Best Answer

The correct CDF for $X$ would be $$F_X(x) = \begin{cases} 0 & x < \theta - 2 \\ \frac{x-(\theta-2)}{4} &x \in [\theta-2,\theta+2] \\ 1 & x > \theta +2\end{cases}.$$ If you use this, then you should get the correct density for the median. Also note that this explains why your formula only holds for $\theta=2$.