I will be attempting the below:
CHAPTER 6. Expected Value and Variance
Exercise 18
Exactly one of six similar keys opens a certain door. If you try the keys, one after another, what is the expected number of keys that you will have to try before success?
The probability(p(x)) of each being the right key is 1/6. The expected number of keys that we have to try can be calculated as below.
E(x) = p(x)x = (1/6)(1+2+3+4+5+6) = (1/6)*21 = 21/6 = 7/2 = 3.5
E <- (1/6)*(1+2+3+4+5+6)
E
## [1] 3.5