Sums of Two, Three, and Four Independent U -shaped Random Variables
Let
be a random sample of size 2 from a
U
-shaped distribution with p.d.f. f(
x
) = (3/2)
, -1 <
x
< 1. Let
=
=
Find the joint p.d.f. of
and
. Then integrate out
to find the p.d.f. of
, the sum of
and
.
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; |
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]); |
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]); |
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]); |
| > | 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]); |
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]); |
| > | g := simplify(piecewise(x < -2,0, x < 0, int(h, y = -1 .. x + 1), x < 2, int(h, y = x - 1 .. 1),0)); |
| > | 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]); |
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
(
)
and a third
U
-shaped random variable
(
)
.
| > | 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]); |
| > | 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]); |
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]); |
| > | h := subs(x = x - y, g)*subs(x = y, f); |
| > | 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)); |
| > | 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]); |
| > | 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]); |
| > | 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]); |
| > | 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]); |
| > | 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]); |
| > |