Let \(x_{1}\) and \(x_{2}\) be independent random variables with common distribution:
Find the distribution of the sum \(x_{1} + x_{2}\).
Answer
# Let X be equal to X1 + X2
paste('Let X be equal to X1 + X2')
## [1] "Let X be equal to X1 + X2"
# P(X = 0)
zero <- 1/8 * 1/8
paste('P(X = 0) =', zero)
## [1] "P(X = 0) = 0.015625"
# P(X = 1)
one <- (1/8 * 3/8) + (3/8 * 1/8)
paste('P(X = 1) =', one)
## [1] "P(X = 1) = 0.09375"
# P(X = 2)
two <- (1/8 * 1/2) + (3/8 * 3/8) + (1/2 * 1/8)
paste('P(X = 2) =', two)
## [1] "P(X = 2) = 0.265625"
# P(X = 3)
three <- (3/8 * 1/2) + (1/2 * 3/8)
paste('P(X = 3) =', three)
## [1] "P(X = 3) = 0.375"
# P(X = 4)
four <- 1/2 * 1/2
paste('P(X = 4) =', four)
## [1] "P(X = 4) = 0.25"
# Make sure the sum of all probabilities is equal to 1.
sum <- zero + one + two + three + four
paste('Sum of all probabilities =', sum)
## [1] "Sum of all probabilities = 1"