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: Sum of two continuous uniform random variables.

  1. Apr 25, 2010 #1
    Z = X + Y

    Where X and Y are continuous random variables defined on [0,1] with a continuous uniform distribution.

    I know we define the density of Z, fz as the convolution of fx and fy but I have no idea why to evaluate the convolution integral, we consider the intervals [0,z] and [1,z-1].

    I googled for articles regarding this particular example but so far every one I read seem to jump directly from integrating the convolution over the real number line to integrating it over these intervals. Why?

    Thanks a lot for any help!
  2. jcsd
  3. Apr 25, 2010 #2


    User Avatar
    Homework Helper

    can you elaborate?

    i would think the convolution should be something like
    [tex] f_Z(z) = \int_0^1 f_X(x) f_Y(z-x)dx [/tex]
    which is defined as an integration over x (or equivalently y), not z?
  4. Apr 25, 2010 #3
    OK, so in general we have for independent random variables X and Y with distributions fx and fy and their sum Z = X + Y:

    f_Z(z) = \int_{-\infty}^{\infty} f_X(x) f_Y(z-x)dx

    Now for this particular example where fx and fy are uniform distributions on [0,1], we have that fx(x) is 1 on [0,1] and zero everywhere else.

    So we have:
    f_Z(z) = \int_0^1 f_Y(z-x)dx

    fy(x) is 1 on [0,1] and zero everywhere else as well.

    So now let's think about what can happen with z. Suppose z is between 0 and 1. Then what's fy(x)? Well, if x is below z, then fy(x) is 1. If x is above z, then fy is zero. So the integrand is 1, but only from x = 0 to x = z. So for [tex] z \in [0,1] [/tex],

    f_Z(z) = \int_0^1 f_Y(z-x)dx = \int_0^z dx

    Now consider z between 1 and 2. Now it's a different problem; if z - x > 1, then fy is zero. But x can go all the way up to 1. So we have for [tex] z \in [1,2] [/tex],

    f_Z(z) = \int_0^1 f_Y(z-x)dx = \int_{z-1}^1 dx
    Last edited: Apr 25, 2010
  5. Apr 25, 2010 #4
    Thanks so much for the great help!

    hgfalling :
    how do u know to separate the range of values of z into two cases, 1 < z < 2 and 0 < z < 1? Why not any other partition?


    [Edit] Referring to the next paragraph of this post of mine...

    It turn out that I didn't really know what they were talking about. The poster on that thread appears to be wrong since he suggested:

    F(z) = P(Z < z) = P(X+Y < z) = Integrate fx(x)fy(y) dx dy over {(x,y)|x+y < z}

    But fx(x)fy(y) = fx,y(x,y) = joint distribution. I don't think integration the join distribution of X and Y gives the sum?


    I googled up a thread on another forum where one poster suggested fixing z and consider the graph of Y vs X. Then look at points where 0< x,y < 1 (unit square) and the line y = z - x where z is a fixed constant. Then we consider (x,y) that lies in the unit square such that x + y < z. We use this to derive F(z) = P(X+Y < z), which is the distribution function. Then derive the density from there. Using this, it becomes clear that there are two cases depending on the value of z.

    Question : is this "sketch the graph" method viable for most questions like this? Or are there critical exceptions?
    Last edited: Apr 26, 2010
  6. Apr 25, 2010 #5


    User Avatar
    Homework Helper

    the change is exactly related to the graph, in hgfalling's post it is based on when [itex] f_Y(z-x) \neq 0 [/itex] for different values of x, and the cross over point is when z=1, if you re-read the post

    many of these sorts of problems can be solved gemterically, when the probabilty ditributions are simple & independent

    in this case the initial joint prbabilty function for X & Y is one over the unit square, zero elsewhere

    Think about Z= X+Y = c, for some constant c, this will be a line of slope -1, the length of the line segment within the unit square is proportinoal to the probability density function for Z.

    see if you can imaine how this gives you the triangular distribution for Z. The partition you describe will be the same point you get the maximum line length for z, across the diagonal of the unit square...
    Last edited: Apr 25, 2010
  7. Apr 25, 2010 #6
    When solving these problems, using convolutions is kind of symbol manipulationish. So here I was just evaluating the integrals straightforwardly. In that way it was kind of like those multivariate problems where they say "find the volume of this solid that is bounded by these three planes, etc." You have to find all the boundaries and just break up the integral, figure out the bounds, etc.

    You can also do things like sketching and looking to solve for the joint distribution, if you prefer. I'm sure some problems lend themselves to one method or another, but I don't know which are which. :)
  8. Apr 26, 2010 #7
  9. Apr 26, 2010 #8
    Arghhhh...I am so sorry but I am still utterly confused about how to figure out that 0<z<1 and 1<z<2 are two different cases. Did you make a sketch or anything? What is the key to figuring this out? :(

    Maybe it would help if you could lead me to figure out the "cases" for a fresh question? But don't give them to me directly. Just give me clues as to where and how to look.

    Question: Z = X + Y, where X ~ U(0,2) and Y ~ U(1,3). i.e. X and Y are uniformly distributed.


    f_Z(z) = \int_{-\infty}^{\infty} f_X(x) f_Y(z-x)dx

    Since fX(x) = 1/2 for 0 < x < 2 and zero otherwise,

    f_Z(z) = \int_{0}^{2} (1/2) f_Y(z-x)dx

    Now I am stuck. :(

    I know fY(z-x) = 1/2 for 1 < z - x < 3.

    So z -3 < x < z -1. But what can I do with this?
  10. Apr 26, 2010 #9


    User Avatar
    Homework Helper

    ok, so going back to hgfalling's post and expanding, the base form of the integral is:
    f_Z(z) = \int_{-\infty}^{\infty} f_X(x) f_Y(z-x)dx

    [itex] f_X(x) [/itex] is 1 on x in [0,1] and 0 everywhere else, so we are interested only in x in the interval [0,1] and the integral becomes:
    f_Z(z) = \int_0^1 f_Y(z-x)dx

    now similarly [itex] f_Y(y) [/itex] is 1 on [0,1] and zero everywhere else. Now consider [itex] f_Y(z-x) [/itex] this is one when z-x is in [0,1] and zero everywhere else.

    so lets consdier a few cases of z:
    First z=0, as x only varies 0 to 1, z-x varies over [-1,0] so [itex] f_Y(-x) [/itex] is zero in the integrand and the integral becomes:
    f_Z(0) = \int_0^1 f_Y(0 -x)dx = \int_0^1 f_Y(-x)dx= 0

    Second, z=1/2, as x varies 0 to 1, z-x varies over [-1/2,1/2] so [itex] f_Y(1/2-x) [/itex] is 1 upto x=1/2, and 0 for x>1/2 and the integral becomes:
    f_Z(1/2) = \int_0^1 f_Y(1/2 -x)dx = \int_0^{1/2} dx= \frac{1}{2}

    Third, z=1, as x varies 0 to 1, z-x varies over [0,1] so [itex] f_Y(1-x) [/itex] is 1 in the integrand and the integral becomes:
    f_Z(0) = \int_0^1 f_Y(1-x)dx = \int_0^1 dx = 1

    so you can imagine the window of [itex] f_Y(z-x) [/itex] has moved over [itex] f_X(x) [/itex] until they are fully overlapped at z=1. now as z increases it looses overlap - hence the triangular dstribution... this is what give the partition and arises from the action of the convolution integral, sweeping each distribution over the other - that action should help you imagine the triangular distribution as well...

    Fourth, z=3/2, as x varies 0 to 1, z-x varies over [1/2,3/2] so [itex] f_Y(y) [/itex] is 1 after x=1/2, zero elsewhere and the integral becomes:
    f_Z(1/2) = \int_0^1 f_Y(1/2 -x)dx = \int_0^{1/2} dx= \frac{1}{2}

    and so on, you'll see the triangular distribution which you solved for explicitly previously
    Last edited: Apr 26, 2010
  11. Apr 26, 2010 #10


    User Avatar
    Homework Helper

    cleaned above post up a bit
  12. Apr 26, 2010 #11


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Education Advisor

    Take a look at the graphical representation of what convolution is on the Wikipedia article on convolution. It's pretty clear from why the partition arises the way it does.

  13. Apr 26, 2010 #12
    One way to think about it is that the cases occur when the way you get to z changes.

    When we had [0,1] x [0,1], when z was less than 1, we knew that the range of acceptable x values could be zero, but couldn't be above z. Once z was greater than 1, though, then we knew that x had to be at least as large as 1-z, and could go all the way to 1.

    So we have an "acceptable interval" of [0,z] ... until z hits 1, at which point our "acceptable interval" shifts to [1-z,1]. If x is outside this "acceptable interval," then we can't make z = x+y.

    h(z) = [0,z], z<=1
    h(z) = [1-z,1], z>1

    Now in your other example X ~ [0,2], Y ~ [1,3], the range of possible z values is [1,5]. Now write a function that is the range of acceptable x-values for all the possible z-values.

    Fill in the ??s:
    h(z) = [0,??], z < ??
    h(z) = [??,2], z > ??
  14. Apr 26, 2010 #13
    Thanks for the help guys! I dont know why this particular type of question is so tough for me. Maybe it is because I have no experience in evaluating convolutions? Would reading a calculus text on evaluating convolutions help?

    vela :

    The images in wiki helped a lot. Thanks! Can I deduce that all convolutions will have a "peak" when the area of overlap is maximum?

    lanedance :

    Your extensive step by step explanation helped me completely visualize the "triangular" density of Z. Now I know perfectly why we break the possible values of z into (0,1) and (1,2). Very grateful that you took the time to write such a detailed explanation. Thanks!

    hgfalling :

    Yes, your last reply makes it a lot clearer. Thanks! I will go work out the new example using your hints and suggested method. But I have two more questions which I think will be the key to making me understand this. (been stuck for two days :( )

    Qns - In the example in the OP, for 0<z<1, we know x lies in (0,z) so we replaced the limits of integration accordingly. We also replaced the integrand by 1 because we know it takes this value for all x within the limits of integration. But...do u mind stating the function explicitly? It is not still integrate[0,z] fy(z - x) dx right? Is it fy(x) after changing the limit?

    Qns - Z = X+Y as usual. But what if X and Y have continuous exponential with parameter L? I know x and y can take 0 to infinity and so z too takes 0 to infinity. So what is the limits? I have a feeling knowing what the integrand is in the first example would help me figure this out on my own.
  15. Apr 27, 2010 #14
    Please verify my logic in this attempt at a solution! I know my answer is correct but I want to know if my logical process is sound. :p

    First, I need to determine where the "peak" is. For this I sketched the density of Z by considering values of z = 1,2,3,4,5. The peak appears to be at 3. So I conclude that I must consider the intervals [1,3] and [3,5].

    *I thought a faster way to use in the future would be to assume that the peak is in the center of the interval of possible z values. But realized this only works for sum of two continuous distributions. Right? For other types of distributions, the peak could be non-centered?

    So we consider two cases:

    1) 1 < z < 3 --- (a)

    We need 1 < z - x < 3 <=> z -3 < x < z-1.

    From (a), we know 0 < z -1 < 2. So x < z-1, since z-1 < 2, the "least upper bound" is relevant for x.

    From (a), we know -2 < z - 3 < 3. So z-3 is not as relevant for x as a lower bound as 0 is.

    So I conclude 0 < x < z - 1.

    2) 3 < z < 5 --- (b)

    We need 1 < z - x < 3 <=> z -3 < x < z-1.

    From (b), we know 0 < z-3 < 2 and 2 < z -1 < 4.

    0 < z-3 => z-3 is "more relevant" as a lower bound. So z-3 < x.
    2 < z-1 => z-1 is "less relevant" than 2 as an upper bound. So x < 2.

    So I conclude z-3 < x < 2.


    h(z) = [0,z-1], 1< z < 3
    h(z) = [z-3,2], 3 < z < 5
  16. Apr 27, 2010 #15
    This logic seems to fail when considering X ~ exponential (L) and Y ~ exponential (L). Because X and Y have the exponential distribution, they take values in [0,infinity).

    Z = X + Y, so z can take values in [0,infinity) too.

    1) So should I replace the limits of integration from (-infinity,infinity) to [0,infinity) because x takes value in that interval?

    2) Is my logic correct in deducing that because 0 < or = (z-x), we need x < or = z? So the upper limit of x is z? Cause if x > z, we get a negative value for (z-x) and then fy(z-x) will ber 0.

    3) There is no peak or multiple cases here? Why?

    4) The lower limit of x should be 0. Because I do not see any "more relevant" lower limit for x? Actually, I am a little uneasy about the lower limit. I keep thinking : "how do I know there isn't another "more relevant" lower limit, e.g. g(z) < x?"
  17. May 1, 2010 #16
    Hey guys,

    I've been reading this up (thanks for the detailed explanation!). My question is what if Z = 2X+Y? How would the distribution of fz change?
  18. May 1, 2010 #17
    Re: sum of exponentials.

    The sum of exponentials doesn't have this triangular distribution and you don't have to split the integral up, since there's no value of x for which a particular value of z which is greater than x isn't possible. With the uniform distributions this did happen, eg x = 0.1, z = 1.2.

    Re: 2X + Y

    Well, this is the same problem, except that fx has changed. Instead of being 1 over the interval [0,1], it's 1/2 over the interval [0,2]. Likewise the convolution integral will have fy(z - 2x), or you could alternately rename 2x to u or something if that will help you keep it straight. Other than that it's pretty straightforward.
  19. May 2, 2010 #18
    could you please elaborate?
    i am not sure how the intervals are going to split.
    i know that for
    assuming that Fy(y) is defined for 0<y<1
    and X~U[0,2] Y~[0,1]
    so 0<z-x<1 and 0<x<2
    0<z<1, x can take on values 0 to z
    for interval
    1<z<2 x can only take on z-1 to z
    for interval
    2<z<3 x can take on z-1 to 2
  20. May 2, 2010 #19
    OK so:

    Let Z = X + Y, where X is uniform on [0,2] and Y is uniform on [0,1].

    [tex]f_Z(z) = \int_{-\infty}^{\infty} f_X(x) f_Y(z-x)dx [/tex]

    X can go from 0 to 2, and fx is 1/2.

    [tex]f_Z(z) = \int_{0}^{2} \frac{1}{2} f_Y(z-x) dx [/tex]

    Now if [itex] z \leq 1 [/itex], then [itex] f_Y [/itex] is 1 if [itex] z < x [/itex] and 0 if [itex] z > x [/itex].

    If [itex] 1 \leq z \leq 2 [/itex], then [itex] f_Y [/itex] is 0 if [itex] z - 1 < x [/itex] and 0 if [itex] z > x [/itex] but 1 in between.

    If [itex] 2 \leq z \leq 3 [/itex], then [itex] f_Y [/itex] is 0 if [itex] z - 1 < x [/itex] but 1 otherwise.

    [tex]f_Z(z) = \int_0^z \frac{1}{2} dx = \frac{z}{2} [/tex]
    [tex]f_Z(z) = \int_{z-1}^z \frac{1}{2} dx = \frac{1}{2} [/tex]
    [tex]f_Z(z) = \int_{z-1}^2 \frac{1}{2} dx = \frac{3-z}{2} [/tex]

    So we have:
    [tex] f_Z(z)=\left\{\begin{array}{cc}\frac{z}{2} ,&\mbox{ if }
    0 \leq z \leq 1 \\ \frac{1}{2} & \mbox{ if } 1 \leq z \leq 2 \\ \frac{3-z}{2} & \mbox{ if } 2 \leq z \leq 3 \end{array}\right. [/tex]
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook