1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Distribution Difference of Two Independent Random Variables

  1. Dec 8, 2014 #1
    1. The problem statement, all variables and given/known data
    Z = X - Y and I'm trying to find the PDF of Z.

    2. Relevant equations

    3. The attempt at a solution

    Started by finding the CDF:
    Fz(z) = P(Z ≤ z)

    P(X - Y ≤ z)

    So I drew a picture

    So then should Fz(z) be:
    since, from my graph, it looks as though Y can go from negative infinity to positive infinity, and X can go from negative infinity on the left but is bounded by z+y on the right

    then should the pdf be:
    Edit: sorry I forgot to include the fact that, because fx and fy are independent, f(x,y) = fxfy in the following derivation
    Last edited: Dec 8, 2014
  2. jcsd
  3. Dec 9, 2014 #2

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    What is your question?
  4. Dec 9, 2014 #3


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Gold Member
    2017 Award

    Your approach looks reasonable. Is there something you are particularly worried about?
  5. Dec 9, 2014 #4
    Oh yes, sorry I was wondering if what I arrived at for the PDF of the difference of two independent random variables was correct.
    I tried Googling but all I could find was the pdf of the sum of two RVs, which I know how to do already.
  6. Dec 9, 2014 #5


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Gold Member
    2017 Award

    Yes, it looks ok. You should note that if you know the pdf of the sum and the pdf of the negative of a distribution (i.e., if you know how the the distribution of ##Y##, what is the distribution of ##-Y##), then you can use these two to obtain the distribution of ##X-Y##.
  7. Dec 9, 2014 #6
    I'm going to modify the problem a little bit, can you tell me if I do it right/wrong?

    X and Y are two independent random variables, each of which are uniform on (0,1). Find the pdf of Z = X - Y

    Using my result from above, the pdf of Z is given by:
    X ~ U(0,1) and Y ~ U(0,1)

    The pdf of fx(x) and fY(y) are both 1 on (0,1) and 0 otherwise.

    z goes from -1 to 1 because of X - Y right?

    For -1 ≤ z ≤ 0
    fy is uniform only on (0,1) so my integral limits should be z+1 to z

    For 0 ≤ z ≤ 1 I wouldn't need to change the limits here, just from 0 to 1

    So then the pdf of X - Y is:

    Is this correct?
  8. Dec 9, 2014 #7

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    No, it cannot possibly be correct, because you would have f(z) = -1 for -1 < z < 0 and f(z) = 1 for 0 < z < 1. That kind of f cannot be a probability density function.

    You need to go back and evaluate the limits more carefully; in cases like this, drawing an x,y diagram of the integration region would be helpful.
  9. Dec 9, 2014 #8
    I don't have much practice drawing integration regions of density functions and I wouldn't know where to start with this one besides drawing the box with vertices (0,0), (0,1), (1,0), (1,1).

    I think I found another way to look at it though:

    If -1 ≤ z ≤ 0,

    If I want fx(z+y) to be 1, I need to shift the bounds by +1, and then I'll need z+y+1 ≥ 0 , or y ≥ -1-z


    Then on 0 ≤ z ≤ 1,

    I need z+y ≤ 1, or y ≤ 1 - z


    Then all together this is:

    1 + z , -1 ≤ z ≤ 0
    1 - z , 0 ≤ z ≤ 1

    I got the same answer as here: http://www.math.wm.edu/~leemis/chart/UDR/PDFs/StandarduniformStandardtriangular.pdf
    but I'm not sure my process is correct because my bounds are a little different than theirs, and I don't know how they computed the cdf
  10. Dec 9, 2014 #9

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    You already drew part of the diagram in Post #1. You just need to add the boundary lines x = 0, x = 1, y = 0, y = 1 and you are done---that's your drawing!

    You say you "don't know how they computed the cdf". Well, you claimed before that you know how to compute the cdf of a SUM, and that is all you need to do.

    If ##Z = X-Y## then ##S = Z+1## has the form ##S = X + (1-Y) = X + Y'##, where ##X## and ##Y' = 1-Y## are independent and ##\rm{U}(0,1)## random variables. Thus, ##S## is the sum of two uniforms, and has a well-known, widely-documented triangular density:
    [tex] f_S(s) = \begin{cases} s, & 0 < s < 1\\ 2-s, & 1 < s < 2\\
    0 & \rm{elsewhere}
    \end{cases} [/tex]
    Now just shift the graph of ##f_S(s)## one unit to the left, and that would be your density of ##Z##: ##f_Z(z) = f_S(1+z), \; -1 < z < 1##.
    Last edited: Dec 9, 2014
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted