Sums of Two, Three, and Four   Independent U -shaped Random Variables

Let   X[1], X[2]  be a random sample of size 2 from a U -shaped distribution with p.d.f. f( x ) = (3/2) x^2 , -1 < x  < 1. Let

Y[1]  =   X[1]+X[2]  

Y[2]  = X[2]  

Find the joint p.d.f. of   Y[1]  and Y[2] .  Then integrate out y[2]  to find the p.d.f. of Y[1] , the sum of X[1]  and X[2] .

A procedure for finding the p.d.f. of the sum of two continuous random variables is given. And then this is illustrated graphically.

Let the p.d.f. of  X  be positive on the interval [ a, b ], where a  and b  are finite. The following procedure will find the p.d.f. of the sum of a random sample of size 2 from this distribution in which the p.d.f. is defined as an expression in x.

A convolution formula. [See Exercise 5.2-12(c), page 233.]

>    with(plots):

Warning, the name changecoords has been redefined

>    SumX1X2 := proc(expr::algebraic, a, b);
piecewise(y[1] < 2*a, 0, y[1] < a + b, int(subs(x = y[1] - y[2], expr)*subs(x = y[2], expr), y[2] = a .. y[1] - a), y[1] < 2*b, int(subs(x = y[1] - y[2], expr)*subs(x = y[2], expr), y[2] = y[1] - b .. b), 0);
end;

SumX1X2 := proc (expr::algebraic, a, b) piecewise(y[1] < 2*a,0,y[1] < a+b,int(subs(x = y[1]-y[2],expr)*subs(x = y[2],expr),y[2] = a .. y[1]-a),y[1] < 2*b,int(subs(x = y[1]-y[2],expr)*subs(x = y[2],expr...
SumX1X2 := proc (expr::algebraic, a, b) piecewise(y[1] < 2*a,0,y[1] < a+b,int(subs(x = y[1]-y[2],expr)*subs(x = y[2],expr),y[2] = a .. y[1]-a),y[1] < 2*b,int(subs(x = y[1]-y[2],expr)*subs(x = y[2],expr...
SumX1X2 := proc (expr::algebraic, a, b) piecewise(y[1] < 2*a,0,y[1] < a+b,int(subs(x = y[1]-y[2],expr)*subs(x = y[2],expr),y[2] = a .. y[1]-a),y[1] < 2*b,int(subs(x = y[1]-y[2],expr)*subs(x = y[2],expr...
SumX1X2 := proc (expr::algebraic, a, b) piecewise(y[1] < 2*a,0,y[1] < a+b,int(subs(x = y[1]-y[2],expr)*subs(x = y[2],expr),y[2] = a .. y[1]-a),y[1] < 2*b,int(subs(x = y[1]-y[2],expr)*subs(x = y[2],expr...

A U -shaped p.d.f.

>    f := 3/2*x^2;
k := 'k':
xtics := [-1+0.2*k$k=0..10]:
ytics := [0.5*k$k=1..3]:
plot(f, x = -1 .. 1, xtickmarks=xtics, ytickmarks=ytics, color=blue, thickness=2, labels=[``,``],font=[COURIER,BOLD,12]);

f := 3/2*x^2

[Maple Plot]

Using the convolution formula, we find the p.d.f. of the sum of two U -shaped random variables.

>    pdf := SumX1X2(f, -1, 1):
pdf := simplify(SumX1X2(f, -1, 1));
xtics := [-2 + 0.4*k$k=0..10]:
ytics := [0.2*k$k=1..4]:
plot(pdf, y[1] = -2 .. 2, y=0 .. 0.92, xtickmarks=xtics, ytickmarks=ytics, color=blue, thickness=2,labels=[``,``], title = `p.d.f. for the Sum of Two U-shaped Random Variables`,font=[COURIER,BOLD,12], titlefont=[COURIER,BOLD,12]);

pdf := PIECEWISE([0, y[1] < -2],[3/40*y[1]^5+3/2*y[1]^2+9/4*y[1]+9/10, y[1] < 0],[9/10-3/40*y[1]^5+3/2*y[1]^2-9/4*y[1], y[1] < 2],[0, 2 <= y[1]])

[Maple Plot]

The following illustrates graphically what the convolution formula does.

>    g := f*subs(x = y, f);   # product of two p.d.f.'s
plot3d(g, x = -1 .. 1, y = -1 .. 1, axes=boxed, orientation=[-66,60],title = `Joint p.d.f. of Two U-shaped Random Variables`, font=[COURIER,BOLD,12], titlefont=[COURIER,BOLD,12]);

g := 9/4*x^2*y^2

[Maple Plot]

>    h := subs(x = x - y, f)*subs(x = y, f);  # Integrating out y is the convolution formula
plot3d(h, x = y - 1 .. y + 1, y = -1 .. 1, axes=boxed, orientation=[-90, 0], title = `Domain of Integration for the Convolution Formula`,font=[COURIER,BOLD,12], titlefont=[COURIER,BOLD,12]);

h := 9/4*(x-y)^2*y^2

[Maple Plot]

The above graph gives only the domain of integration. The following graph shows the surface over this domain.

>    h := subs(x = x - y, f)*subs(x = y, f);  # Plot h over the domain of integration
hplot := plot3d(h, x = y - 1 .. y + 1, y = -1 .. 1, axes=boxed, orientation=[-66,60], title = `Integrate over y to find the p.d.f. of the\nSum of 2 U-shaped Random Variables`, titlefont=[COURIER,BOLD,12]):
t := 't':
S1 := spacecurve([0,-1,t],t=0..9/4,axes=boxed, orientation=[-66,60],color=black):
S2 := spacecurve([0,t,9/4],t=-1..1,axes=boxed, orientation=[-66,60],color=black):
S3 := spacecurve([0,1,t],t=0..9/4,axes=boxed, orientation=[-66,60],color=black):
S4 := spacecurve([0,t,0],t=-1..1,axes=boxed, orientation=[-66,60],color=black):
display({hplot,S1,S2,S3,S4}, font=[COURIER,BOLD,12]);

h := 9/4*(x-y)^2*y^2

[Maple Plot]

>    g := simplify(piecewise(x < -2,0, x < 0, int(h, y = -1 .. x + 1), x < 2, int(h, y = x - 1 .. 1),0));

g := PIECEWISE([0, x < -2],[3/40*x^5+3/2*x^2+9/4*x+9/10, x < 0],[9/10-3/40*x^5+3/2*x^2-9/4*x, x < 2],[0, 2 <= x])

>    plot(g, x = -2 .. 2, color=blue, thickness=2, xtickmarks=xtics, ytickmarks=ytics, labels=[``,``], title = `Graph of the p.d.f. of the Sum of Two U-shaped Random Variables`, font=[COURIER,BOLD,12], titlefont=[COURIER,BOLD,12]);

[Maple Plot]

Using g, the p.d.f. for the sum of two U -shaped random variables and f, the p.d.f. of a single U -shaped random variable, plot the joint p.d.f.   of the sum of two

U -shaped random variables ( X[1]+X[2] )   and a third U -shaped random variable ( X[3] ) .

>    plot3d(g*subs(x=y,f), x = -2 .. 2, y = -1 .. 1, axes=boxed, orientation=[-68,56], title = `Joint p.d.f. of the Sum of 2 and of 1\nU-shaped Random Variables`, font=[COURIER,BOLD,12], titlefont=[COURIER,BOLD,12]);

[Maple Plot]

>    h := subs(x = x - y, g)*subs(x = y, f):
plot3d(h, x = y - 2 .. y + 2, y = -1 .. 1, axes=boxed, orientation=[-68,56],title = `Integrate Out y to Find the p.d.f. of the\nSum of 3 U-shaped Random Variables`, font=[COURIER,BOLD,12], titlefont=[COURIER,BOLD,12]);

[Maple Plot]

Here is the domain of integration.

>    h := subs(x = x - y, g)*subs(x = y, f):
plot3d(h, x = y - 2 .. y + 2, y = -1 .. 1, axes=boxed, orientation=[-90, 0],title = `Domain of Integration`, font=[COURIER,BOLD,12], titlefont=[COURIER,BOLD,12]);

[Maple Plot]

>    h := subs(x = x - y, g)*subs(x = y, f);

h := 3/2*PIECEWISE([0, x-y < -2],[3/40*(x-y)^5+3/2*(x-y)^2+9/4*x-9/4*y+9/10, x-y < 0],[9/10-3/40*(x-y)^5+3/2*(x-y)^2-9/4*x+9/4*y, x-y < 2],[0, 2 <= x-y])*y^2

>    g := simplify(piecewise(x <= -3,0, x < -1, int(h, y = -1 .. x + 2), x = -1, 51/140, x < 1, int(h, y = -1 .. 1),x = 1, 51/140, x < 3, int(h, y = x - 2 .. 1),0));

g := PIECEWISE([0, x <= -3],[405/112*x+27/16*x^2+1701/640+27/64*x^4+9/80*x^5+3/4480*x^8+27/40*x^3, x <= -1],[27/320+9/8*x^2-27/32*x^4-3/2240*x^8, x <= 1],[-405/112*x-9/80*x^5+3/4480*x^8-27/40*x^3+1701/...

>    xtics := [-4 + 0.5*k$k=0..16]:
ytics := [0.1*k$k=1..5]:
plot(g, x = -4 .. 4, xtickmarks=xtics, ytickmarks=ytics, labels=[``,``], thickness=2, color=blue, title = `Graph of the p.d.f. of the Sum of Three U-shaped Random Variables`, font=[COURIER,BOLD,12], titlefont=[COURIER,BOLD,12]);

[Maple Plot]

>    plot3d(subs(y[1] = x, pdf)*subs(y[1] = y, pdf), x = -2 ..2, y = -2 .. 2, axes=boxed, orientation=[-63,52], title = `Joint p.d.f. of Sum of 2 and Sum of 2\nU-shaped Random Variables`, font=[COURIER,BOLD,12], titlefont=[COURIER,BOLD,12]);

[Maple Plot]

>    plot3d(subs(y[1] = x - y, pdf)*subs(y[1] = y, pdf), x = y - 2 .. y +2, y = -2 .. 2, grid = [119,59], axes=boxed, orientation=[-68,56], title = `Integrate Out y to Find the p.d.f. of the\nSum of 4 U-shaped Random Variables`, font=[COURIER,BOLD,12], titlefont=[COURIER,BOLD,12]);

[Maple Plot]

>    plot3d(subs(y[1] = x - y, pdf)*subs(y[1] = y, pdf), x = y - 2 .. y +2, y = -2 .. 2, grid = [119,59], axes=boxed, orientation=[-90, 0],title = `Domain of Integration`, font=[COURIER,BOLD,12], titlefont=[COURIER,BOLD,12]);

[Maple Plot]

>    h := subs(y[1] = x - y, pdf)*subs(y[1] = y, pdf):
g := simplify(piecewise(x <= -4,0, x < 0, int(h, y = -2 .. x + 2),  x < 4, int(h, y = x - 2 .. 2),0)):

>    xtics := [-4 + 1*k$k=0..8]:
ytics := [0.05*k$k=1..10]:
plot(g, x = -4.5 .. 4.5, xtickmarks=xtics, ytickmarks=ytics, labels=[``,``], thickness=2, color=blue, title = `Graph of the p.d.f. of the Sum of Four U-shaped Random Variables`, font=[COURIER,BOLD,12], titlefont=[COURIER,BOLD,12]);

[Maple Plot]

>