# Deriving mass/density functions of variables $\log(X)$, $X+Y$, $\operatorname{sgn}(X-1/2)$.

Could you help me with the following question?

Suppose that a point with co-ordinates $(X,Y)$ is chosen uniformly from the square $\{(x,y)\in \mathbb{R}^2: 0 \leq x,y \leq 1\}$. For each of the following random variables derive its mass/density function.

(i) $\log(X)$

(ii) $X+Y$

(iii) $\operatorname{sgn}(X-1/2)$

First of all the densifty function of X I would define as $f_x(x)=1$ for $0 \leq x \leq 1$. So that for $\log(X)$ it should be $f_Y(y)=\frac{f_x(x)}{(\log(x))'}=x=e^y$ for $-\infty \le y \leq 0$. Am I right?

How to solve points (i) and (ii), have you got any suggestions? I would really appreciate your help.

For (ii), one method is to integrate the joint density function over a suitable region:

\begin{eqnarray*} F_{X+Y}(z) &=& \iint_{x+y\lt z} f_{X,Y}(x,y)\;dy\,dx. \end{eqnarray*}

To evaluate, there are two cases:

For $0\lt z\leq 1$: \begin{eqnarray*} F_{X+Y}(z) &=& \int_{x=0}^{z} \int_{y=0}^{z-x}1\;dy\,dx \\ &=& \int_{x=0}^{z} (z-x)\;dx \\ &=& z^2/2. \\ \therefore\quad\text{Differentiating,}\quad f_{X+Y}(z) &=& z. \end{eqnarray*}

For $1\lt z\leq 2$: \begin{eqnarray*} F_{X+Y}(z) &=& \int_{x=0}^{z-1} \int_{y=0}^{1}1\;dy\,dx + \int_{x=1-z}^{1} \int_{y=0}^{z-x}1\;dy\,dx \\ &=& \int_{x=0}^{z-1} 1\;dx + \int_{x=1-z}^{1} (z-x)\;dx \\ &=& 2z-1+z^2/2. \\ \therefore\quad\text{Differentiating,}\quad f_{X+Y}(z) &=& 2-z. \end{eqnarray*}

Therefore, we have

$$f_{X+Y}(z) = \begin{cases} z, & \text{if 0\lt z\leq 1} \\ 2-z, & \text{if 1\lt z\leq 2.} \end{cases}$$

Note, you can also find the distribution function for $X+Y$ geometrically by find the area of the region $x+y\lt z$ inside the unit square $[0,1]^2$.

For (iii),

\begin{eqnarray*} P(\operatorname{sgn}(X-1/2)=-1) &=& P(X-1/2\lt 0) = 1/2 \\ P(\operatorname{sgn}(X-1/2)=1) &=& P(X-1/2 \gt 0) = 1/2. \end{eqnarray*}