# Distribution of the difference of two independent uniform variables, truncated at 0

Let $X$ and $Y$ be two independent random variables having the same uniform distribution $U(0,1)$ with density

$f(x)=1$ if $0≤x≤1$ (and $0$ elsewhere).

Let $Z$ be a real random variable defined by:

$Z=X-Y$ if $X>Y$ (and $0$ elsewhere).

1. Derive the distribution of $Z$.

2. Compute the expectation $E(Z)$ and variance $V(Z)$.

-
Homework? What have you tried and where are you stuck? Do you know how to find the distribution of a sum of independent random variables. If you do then, hint: $X - Y = X + (-Y)$. That said, your question doesn't seem to be asking about the distribution of a (pure) subtraction. So, providing some details on your thought process will help users here guide you in the right direction. –  cardinal Nov 9 '11 at 17:44
i am preparing for an exam after leaving university for 5 years and working in a totally different field that has nothing to do even with numbers. –  Majed Hijazi Nov 9 '11 at 18:15
my problem here starts with the logic of the problem. i know it has to do with probability density function, but adding or subtracting the functions is getting me nowhere. another thing is the difference between the part 1 and 2 as i know that the distribution of the varibale is knowing its mean and variance and part 2 is asking the same question. i hope someone can help me with this as i dont have much time in preparation and it is the first time i get to such kind of problems while preparing. thanks to all in advance –  Majed Hijazi Nov 9 '11 at 18:17
The distribution is more than just the mean and variance, so you should review the distinction among the three. Then consider relying on first principles. E.g., drawing a picture of the joint distribution of $(X,Y)$ in the $x,y$-plane along with level curves of $Z=X-Y$ will provide an immediate (and easy) geometric derivation of the distribution of $Z$. –  whuber Nov 9 '11 at 18:29
Hint: Since $P\{X < Y\} = \frac{1}{2}$ (think about why this must be so), $Z$ has value $0$ with probability $\frac{1}{2}$. Thus, $Z$ is what is sometimes called a mixed random variable which takes on some values with nonzero probability and behaves as a continuous random variable for some values. As @whuber does, I too ask whether you have mis-stated the problem. It leads to more complications than one would expect from a typical end-of-chapter problem at the apparent level of the book you are using. –  Dilip Sarwate Nov 10 '11 at 12:50