# Independent and uniformly distributed on $(\frac{1}{2},1]$

I have two random variables $X,Y$ which are independent and uniformly distributed on $(\frac{1}{2},1]$. Then I consider two more random variables, $D=|X-Y|$ and $Z=\log\frac{X}{Y}$. I would like to calculate both, the disitrbution functions $F_D(t), F_Z(t)$ and the the density functions $f_D(t),f_Z(t)$

To do that I think the first thing we need to do is to evaluate the density of the common distribution of $X$ and $Y$, but I do not know how to do that.

The only thing which is clear to me is the density and distribution function of $X$ and $Y$ because we know that they are uniform.

EDIT: Please read my own answer to this question. I need someone who can show me my claculation mistakes.

-
What do you mean by "normally distributed on $(1/2,1]$? Uniformly distributed, perhaps? – Jakub Konieczny May 19 '13 at 13:46
Yes of course, sorry for that. I edited the post. – Montaigne May 19 '13 at 13:55

The area of a $\color{red}{\mathrm{right\ triangle}}$ being half the product of its legs is all that one needs, really...

For example, $D\geqslant x$ with $0\leqslant x\leqslant\frac12$ means that $(X,Y)$ is either in the triangle $\color{red}{T_x}$ with vertices $(\frac12+x,\frac12)$, $(1,\frac12)$, $(1,1-x)$ or in the triangle $\color{red}{S_x}$ symmetric of $\color{red}{T_x}$ with respect to the first diagonal. Both legs of $\color{red}{T_x}$ are $\frac12-x$, the triangles $\color{red}{T_x}$ and $\color{red}{S_x}$ are disjoint and with the same area, and the domain of $(X,Y)$ is the full square $(\frac12,1)\times(\frac12,1)$ with area $\frac14$, hence $$P[D\geqslant x]=4\cdot2\cdot|\color{red}{T_x}|=(1-2x)^2=1-4x(1-x).$$ From here, one gets for every $0\leqslant x\leqslant\frac12$, $$F_D(x)=4x(1-x),\qquad f_D(x)=4(1-2x).$$ Likewise, consider $R=\frac{Y}X$, then $\frac12\leqslant R\leqslant2$ and $R$ and $\frac1R$ are identically distributed. For every $\frac12\leqslant x\leqslant 1$, $R\leqslant x$ means that $(X,Y)$ is in the triangle $\color{red}{U_x}$ with vertices $(\frac1{2x},\frac12)$, $(1,\frac12)$, $(1,x)$. The legs of $\color{red}{U_x}$ are $1-\frac1{2x}$ and $x-\frac12$ hence $$P[R\leqslant x]=4\cdot|\color{red}{U_x}|=\frac1{2x}(2x-1)^2.$$ Likewise, for every $1\leqslant x\leqslant2$, $$P[R\geqslant x]=\frac1{2x}(2-x)^2.$$ (This can be proved either by considering the triangle $\color{red}{V_x}$ which corresponds to the event $R\geqslant x$, or directly using the equidistribution of $R$ and $\frac1R$.)

Now, if $Z=\log R$ then, for every $-\log2\leqslant z\leqslant0$, $[Z\leqslant z]=[R\leqslant\mathrm e^z]$ hence $$P[Z\leqslant z]=\frac12\mathrm e^{-z}(2\mathrm e^z-1)^2,$$ and for every $0\leqslant z\leqslant\log2$, $[Z\geqslant z]=[R\geqslant\mathrm e^z]$ hence $$P[Z\geqslant z]=\frac12\mathrm e^{-z}(2-\mathrm e^z)^2.$$ From here, one gets, for every $-\log2\leqslant z\leqslant0$, $$F_Z(z)=\tfrac12\mathrm e^{-z}(2\mathrm e^z-1)^2,\qquad f_Z(z)=2\mathrm e^z-\tfrac12\mathrm e^{-z},$$ and, for every $0\leqslant z\leqslant\log2$, $$F_Z(z)=1-\tfrac12\mathrm e^{-z}(2-\mathrm e^z)^2,\qquad f_Z(z)=2\mathrm e^{-z}-\tfrac12\mathrm e^{z}.$$ The invariance of $f_Z(z)$ by the symmetry $z\mapsto-z$, which follows from the fact that $R$ and $\frac1R$ are identically distributed, should be apparent.

-
First of all, thank you very much. It helped a lot. Still I have some questions. How exactly did you receive the coordinates of the vertices from the triangles? Secondly how do you immediately see that R and 1/R are i.i.d for 1/2<=R<= 2 ? Thirdly, the $4$ in $P(R\le x)$ comes from the area of this triangle, correct? – Montaigne May 26 '13 at 23:33
First: drawing a diagram, this should be obvious (try and tell me if this is not). Second: R and 1/R are identically distributed (not i.i.d.) because (X,Y) and (Y,X) are identically distributed and because R=u(X,Y) and 1/R=u(Y,X) for a same function u. Third: yes. – Did May 26 '13 at 23:37

Let's try for $D = |X-Y|$: We have, for $t\geq 0$, $$F_D(t) = P[D\leq t] = P[|X-Y|\leq t] = P[-t\leq X-Y \leq t] = P[-t+Y\leq X \leq t+Y] =\int_\mathbb{R}P[-t+y\leq X \leq t+y | Y=y]f_Y(y)dy =\int_\mathbb{R} P[-t+y\leq X \leq t+y]f_Y(y)dy= \\ = \int_\mathbb{R}\int_{-t+y}^{t+y} f_X(x)dx f_Y(y)dy= \dots$$ And you can calculate the rest using what is known about $X$ and $Y$. Note that we needed the independence for this calculation! Of course, $F_D(t) = 0$ for $t<0$. Now the density function:

$$f_D(t)=P[D=t]=P[|X-Y|=t]=\int\int_{\{(x,y);|x-y|=t\}}f_{XY}(x,y)dxdy = \\=\int\int_{\{(x,y);|x-y|=t\}}f_{X}(x)\cdot f_{Y}(y)dxdy = ...$$

And you can again calculate this. Note that we have used the independence again to write the joint density as the product of the densities.

You should be able to deal with $Z$ in an analogous fashion.

-
Thanks, two things: for $f_X$ I get $\frac{1}{1-\frac{1}{2}}$ (density function uniform distribution), the same with $f_Y$, correct? Can some of the events be identified with surfaces in $\mathbb R^2$ ? – Montaigne May 19 '13 at 16:51
Your density function is correct, and it is of course the same for both r.v.'s, since they have the same distribution. Well, $\{D=t\}=\{(x,y),|x-y|=t, x,y\in(1/2,1]\}$ is a set of two parallel lines in $\mathbb{R}^2$, if you mean that. And hence, $\{D\leq t\}$ is the surface in between those lines (including them). – alexlo May 19 '13 at 17:01
Ok, may you take a look on my attempt for $Z$ (I edited my starting post). The bounds for $x,y$ in $f_D(t)$ are therefore $-\infty$ and $+\infty$ correct? – Montaigne May 19 '13 at 17:06
Your attempt for Z is correct, except that you need to multiply directly by the density of Y in the integral when you condition on $Y=y$, because $P(A|B)=P(A\cap B)/P(B) = P(A)$ for independent events $A,B$. In $f_D(t)$ you get a lot of indicator functions, because the uniform density in your case is $2*\mathbb{1}_{(1/2,1]}$ and this gives you bounds for $x$ and $y$. – alexlo May 19 '13 at 17:16
Thanks, still I have problems with the integral bounds. I just tried to calculate $F_D(t)$ but the $\int_{\infty}^{\infty}$ integraöirritates me or do you mean something different with $\int_{\mathbb R}$? I would appreciate it if you could explain me the boundaries in $f_D(t)$ a little bit more in detail. – Montaigne May 19 '13 at 17:24

My goodness ... what a lot of work. The nice thing about using a computer algebra system to solve this is: a) it's basically a one-liner, and b) if it is for a uni course, you will still need to know yourself how to get there, but at least you will know if your workings are correct. Here I am using the mathStatica add-on to Mathematica to do the grunt work.

By independence, the joint pdf of $(X,Y)$ is say $f(x,y)$:

Let $Z$ = Abs$[X-Y]$. The cdf of $Z$ is $P(Z<z)$ = $P($Abs$[X-Y] < z)$:

Let $Z = Log[X/Y]$. The cdf of $Z$ is $P(Z<z) = P(Log[X/Y] < z)$:

All done. Differentiate to get the pdf ...

-

I thought it makes more sense to write an answer myself, but I still need someones help to complete the calculations. Here is my summary:

For $F_D(t)=\int_{\frac{1}{2}}^1\int_{-t+y}^{t+y}f_X(x) dx f_Y(y) dy=\int_{\frac{1}{2}}^1\int_{-t+y}^{t+y} 2*2 dx dy=4t$ for $x\in(1/2,1]$

For $f_D(t)=P(D=t)=\int_{\frac{1}{2}}^1 \int_{\frac{1}{2}}^1 f_X f_Ydx dy=4*1/2*1/2=1$

For $F_Z(t)=\int_\mathbb R\int_0^{y e^t}f_X dx f_Y dy=\int_{\frac{1}{2}}^1\int_0^{y e^t} 2 *2 dx dy=e^t$

For $f_Z(t)=P(Z=t)=\int\int_{\{(x,y): x/y=e^t\}} f_X*f_Y dx dy=?$

Question: May you help me not doing some calculation mistakes, because I think the bounds from the integrals are false. I understood the idea of the example, but still have difficulties getting the correct numbers, especially in the second case (where does $\log(2)$ appears in wolfies answer?)

-
In the very first integral used to compute $F_D(t)$, the interval for $x$ is not $(-t+y,t+y)$ for every $y$ in $(\frac12,1)$ since $x$ is restricted to $(\frac12,1)$. Other similar mistakes explain that your formulas are not correct. – Did May 26 '13 at 23:19