# Sheldon Ross 10: Example 2.18 (Expectation of a Geometric Random Variable)

Question: Calculate the expectation of a geometric random variable having parameter p.

The Probability Distribution Function of a geometric variable is

E[x] = nΣ n p(1-p)n-1 : where 0 ≤ n < ∞ = 1p

Intuitively, this probability can be understood as follows. Let us consider the case of a coin toss and the probability of whether it will be a heads or tails is 0.5 and 0.5. If you are interested in the outcome being heads, 1/0.5 = 2 would mean that in the long run, we would need to wait for two tosses for the outcome to be heads. This does not imply however that the every-other toss is going to be favourable to you. But the outcomes match the expected number in the long run.

We will now do a simulation to see how the outcomes match up.

Code for the plots: I am loading accumulatingMean from a local package and the definition is given below. Probabilities 0.9 & 0.1

In this case the probabilities of Failure and Success are 0.9 and 0.1 respectively. Each horizontal row of squares is a series of trials until a success is obtained. The red rectangles are the failures and the green rectangles at the each row is a success. Notices how over several of these sets of trials, the mean number of trials by the time it is a success is the expected is 10. Probabilities 0.95 & 0.05 End of the post

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.