Sums of Discrete Random Variables

1. Convolution examples using sums of rolls of fair dice.

Let Y[n] equal the sum of n rolls of an m -sided die. Use animation to graph probability histograms of the p.d.f. of Y[n] .

First an example of how the Convolution program works using the sum of two m -sided dice.

> m := 4:
k := 'k':

> domain := [k$k=1..m];
probs := [1/m$k=1..m];
X[1] := zip((x,y)->(x,y),domain,probs);
P1 := ProbHistFill(X[1]):
P2 := plot([[0,0],[0,0]], x = 0 .. 4.7, xtickmarks=domain, labels=[``,``], title = `Probability Histogram, One 4-sided Die`, titlefont=[TIMES,BOLD,14]):
display({P1, P2});

domain := [1, 2, 3, 4]

probs := [1/4, 1/4, 1/4, 1/4]

X[1] := [1, 1/4, 2, 1/4, 3, 1/4, 4, 1/4]

[Maple Plot]

> Y[2] := Convolution(X[1], X[1]);

Y[2] := [2, 1/16, 3, 1/8, 4, 3/16, 5, 1/4, 6, 3/16,...

> k := 'k':
xtics := [k$k=1..8]:
P2 := ProbHistFill(Y[2]):
T := plot([[0,0],[0,0]], x = 0 .. 8.7, xtickmarks=xtics, labels=[``,``], title = `Probability Histogram,\nSum of Two 4-sided Dice`, titlefont=[TIMES,BOLD,14]):
display({P2, T});

[Maple Plot]

Now use animation on n to show the probability histograms for the p.d.f. of the sum of n m -sided dice.

> m := 4: # Number of faces on each die.
n := 5: # Number of dice that are used.
k := 'k':
xtics := [k$k=1 .. n*m]:
domain := [k$k=1..m]:
probs := [1/m$k=1..m]:
X[1] := zip((x,y)->(x,y),domain,probs):
Y[1] := X[1]:
P[1] := ProbHistFill(Y[1]):
P2 := plot([[0,0],[0,0]], x = 0 .. n*m+0.7, xtickmarks=xtics, labels=[``,``]):
tm := textplot([n*m/2,1/m, `m = `||m], font=[TIMES,BOLD,14]):
tn := textplot([n*m/2,.9/m, `n = `||1], font=[TIMES,BOLD,14]):
Pt[1] := display({P2, P[1],tm,tn}):
for j from 2 to n do
Y[j] := Convolution(Y[j-1], X[1]):
P[j] := ProbHistFill(Y[j]):
tm := textplot([n*m/2,1/m, `m = `||m], font=[TIMES,BOLD,14]):
tn := textplot([n*m/2,.9/m, `n = `||j], font=[TIMES,BOLD,14]):
Pt[j] := display({P2, P[j],tm,tn}):
od:
display([seq(Pt[j], j = 1 .. n)], title = `Sum of n m-sided Dice`, insequence=true, titlefont=[TIMES,BOLD,14]);

[Maple Plot]

Change value of m and/or n

Return to Menu

2. Let Y[n] equal the sum of n rolls of an m -sided die. Use animation to graph probability histograms of the p.d.f. of Y[n] . Superimpose a normal p.d.f. with mean mu = n*(m+1)/2 and variance sigma^2 = n*(m^2-1)/12 .

> m := 4: # Number of faces on each die.
n := 7: # Number of dice that are used.
k := 'k':
xtics := [k$k=1 .. n*m]:
domain := [k$k=1..m]:
probs := [1/m$k=1..m]:
X[1] := zip((x,y)->(x,y),domain,probs):
Y[1] := X[1]:
P[1] := ProbHistFill(Y[1]):
tm := textplot([n*m/2,.9/m, `m = `||m], font=[TIMES,BOLD,14]):
tn := textplot([n*m/2,.8/m, `n = `||1], font=[TIMES,BOLD,14]):
mu := (m+1)/2:
var := (m^2 - 1)/12:
normplot := plot(NormalPDF(mu, var, x), x = -0.5 .. n*m+1/2, color=magenta, thickness=2):
P2 := plot([[0,0],[0,0]], x = 0 .. n*m+0.7, xtickmarks=xtics, labels=[``,``]):
Pt[1] := display({P2, P[1],tm,tn}):
for j from 2 to n do
Y[j] := Convolution(Y[j-1], X[1]):
P[j] := ProbHistFill(Y[j]):
tm := textplot([n*m/2,.9/m, `m = `||m], font=[TIMES,BOLD,14]):
tn := textplot([n*m/2,.8/m, `n = `||j], font=[TIMES,BOLD,14]):
mu := j*(m+1)/2:
var := j*(m^2 - 1)/12:
normplot := plot(NormalPDF(mu, var, x), x = -0.5 .. n*m+1/2, color=blue, thickness=2):
Pt[j] := display({P[j],tm,tn,normplot}):
od:
display([seq(Pt[j], j = 1 .. n)], title = `Sum of n m-sided Dice,\nN[n(m + 1)/2, n(m^2 - 1)/12] p.d.f.`, insequence=true, titlefont=[TIMES,BOLD,14]);

[Maple Plot]

Probability Histogram, Sum of n m -sided Dice, N ( n*(m+1)/2 , n*(m^2-1)/12 ) p.d.f.

Change Values of m and/or n

Return to Menu