*** Page 289 Question 3. ***
Find the distribution of the sum \(X_1 + X_2\).
*** Answer *** Let \(Z\) = \(X_1\) + \(X_2\). To compute the distribution of the sum, we need to compute \(P_z(0), P_z(1)\), \(P_z(2), P_z(3), P_z(4)\).
# As given:
px0 = 1/8
px1 = 3/8
px2 = 1/2
# Z can be zero in only 1 way (X1 = 0 and X2 = 0)
pz0 = px0 * px0
# Z can be 1 in 2 ways: (X1, X2) = (0, 1) or (1,0)
pz1 = px0*px1 + px1*px0
# Z can be 2 in 3 ways: (X1, X2) = (0, 2) or (1,1) or (2, 0)
pz2 = px0*px2 + px1*px1 + px2*px0
# Z can be 3 in 2 ways: (X1, X2) = (1, 2) or (2, 1)
pz3 = px1*px2 + px2*px1
# Z can be 4 in 1 way (X1 = 2 and X2 = 2)
pz4 = px2*px2
print("Probability distribution of the sum is as follows for P(0):P(4). ")
## [1] "Probability distribution of the sum is as follows for P(0):P(4). "
print(c(pz0, pz1, pz2, pz3, pz4))
## [1] 0.015625 0.093750 0.265625 0.375000 0.250000