poi5 <- dpois(0:20, lambda = 5)
plot (poi5, pch = 20,
      xlab = "value of x", ylab = "probability", main = "Lines of mean = 5",
      ylim = c(0,0.25))
lines(poi5, lwd = 2)


## the mean of the distribution Poi(5)
mean_poi5 <- sum (0:20 * poi5)
mean_poi5
## [1] 4.999998
## add the following lines (3):

### bin(10,0.5) distribution in red
bin10_0.5 <- dbinom (0:10, size = 10, prob = 0.5)
points(bin10_0.5, col = "red", pch = 17)
lines(bin10_0.5, col = "red", lwd = 2)

# the mean of this bin(10, 0.5) distribution
mean_bin10_0.5 <- sum (0:10 * bin10_0.5)
mean_bin10_0.5
## [1] 5
# the mean of this distribution is 5

### the bin(20, 0.25) distribution in blue and find its mean
bin20_0.25 <- dbinom (0:20, size = 20, prob = 0.25)
points (bin20_0.25, col = "blue", pch = 15)
lines (bin20_0.25, col = "blue", lwd = 2, lty = 3)

# the mean of this bin(20, 0.25) distribution
mean_bin20_0.25 <- sum (0:20 * bin20_0.25)
mean_bin20_0.25
## [1] 5
# the mean of this distribution is  5

### the bin (40, 0.125) distribution in gold and find its mean
bin40_0.125 <- dbinom (0:40, size = 40, prob = 0.125)
points (bin40_0.125, col = "gold", pch = 4)
lines (bin40_0.125, col = "gold", lwd = 2, lty = 8)

# the mean of this bin(40, 0.125) distribution
mean_bin40_0.125 <- sum (0:40 * bin40_0.125)
mean_bin40_0.125
## [1] 5
# the mean of this distribution is  5

abline(v = 5, lty = 2, col = "orchid")

# add a suitable legend and a title which describes what you are demonstrating in the plot

legend ("topright", legend = c("Po(5)", "B(10, 0.5)", "B(20, 0.25)", "B(40, 0.125)"),
        col = c ("black", "red", "blue", "gold"),
        lty = rep ( 1 , times = 3), cex = 0.7)