# Math Help - Calculate PDF of Y-Z given Y>Z

1. ## Calculate PDF of Y-Z given Y>Z

Hi everyone,

I am trying to calculate the PDF of Y-Z given that Y>Z. Random variables Y and Z are independent and uniformly distributed over the interval [0,1].

I have tried calculating |Y-Z| (the PDF is basically a half triangle with height 2 and width 1), but I do not think this is correct. I think that the restriction Y>Z creates a situation where the random variables are not independent, so convolution is not valid.

In trying to understand this problem, I created a Matlab script to look at the empirical PDF. The result is clearly not linear like we would expect from |Y-Z|, but it has a quadratic form of some kind. The Matlab code is listed below.

Any ideas for solving this?

==========================================

clear;
clc;

out = [];

for rounds = 1:30000;

y = rand;
z = rand;

while y<z
z = rand;
end

out = [out y-z];

end

[pdf,xout] = hist(out,100);
pdf = pdf/sum(pdf);
stem(xout,pdf)

2. Maybe, if you posted the entire problem.

3. Thanks for your reply. Although it seems simple, this is the entire problem statement.

Random variables Y and Z are independent and uniformly distributed over the interval [0,1]. Define W=Y-Z and find the PDF f_W(w|Y>Z).