<s>[INST] Density function of average of max and min of uniform random variables Suppose $X_1, \ldots, X_n \sim U(\theta - \frac{1}{2}, \theta + \frac{1}{2})$. I want to find the density of $Z = \frac{X_{(1)} + X_{(n)}}{2}$. My strategy is to use the transformation $F(x, y) = (\frac{x + y}{2}, y)$ and the joint density of $X_{(1)}$ and $X_{(n)}$, which is given by
$$
f(x,y) = n (n-1) (y - x)^{n-2}
$$
if $\theta - \frac{1}{2} < x < y < \theta + \frac{1}{2}$. Note that $F^{-1}(z, y) = (2z - y, y)$. By the transformation law, the joint density of $Z$ and $X_{(n)}$ is given by
$$
g(z,y) = f(F^{-1}(z, y)) |J F^{-1}(z, y) | = n(n-1)(y - (2z - y))^{n-2} \cdot 2 = 2^{n-1} n (n-1) (y - z)
$$
if $\theta - \frac{1}{2} < 2z - y < y < \theta + \frac{1}{2}$. Then I marginalize over $y$ to get the density of $Z$:
$$
g(z) = \int_z^{\theta + \frac{1}{2}} g(z,y) dy = n 2^{n-1}(\theta + \frac{1}{2} - z)^{n-1}
$$
for $\theta - \frac{1}{2} < z < \theta + \frac{1}{2}$. But this is not a density function (doesn't integrate to $1$). The culprit is the factor of $2^{n-1}$. Can someone point to where I went wrong? Much thanks
 [/INST] The mistake is in the integral to find density function of $Z$.
$ \displaystyle \theta - \frac{1}{2} < 2z - y < y < \theta + \frac{1}{2}$ would mean
For $\theta - \frac 12 \lt z \lt \theta, z \lt y \lt 2z + \frac 12 - \theta$
And for $\theta \lt z \lt \theta + \frac 12, z \lt y \lt \theta + \frac 12$
Integrating you get,
$ \displaystyle g(z) = n \cdot 2^{n-1} \cdot \left(\frac 12 + z - \theta\right)^{n-1} ~, \theta - \frac 12 \lt z \lt \theta$
$ \displaystyle g(z) = n \cdot 2^{n-1} \cdot \left(\frac 12 + \theta - z \right)^{n-1} ~, \theta \lt z \lt \theta + \frac 12$
</s>