Chapter 2 Section 3 Question 20
Suppose that there is a loop in a computer program and that the test to exitthe loop depends on the value of a random variable X. The program exits the loop whenever $X \in \mathbb{A}$, and this occurs with probability $1/3$. If the loop is executed at least once, what is the probability that the loop is executed five times before exiting?
Author: Mohammad-Ali Bandzar| Date:Oct 19 2020
Since we are trying to calculate number of failures before the first success and all our trials are independent we have a geometric distribution
From Example 2.3.4 in the book we know: $$p\scriptsize{X}\normalsize{(x)=P(X=x)=(1-\theta )^x\theta}$$ $\theta$ is the probability of success per event in this case $\theta=\frac{1}{3}$
x represents the number of failed events before a success. In this case we want 4 failures before a success so $x=4$
$$P(X=x)=(1-\theta )^x\theta}$$ $$P(X=4)=(1-\frac{1}{3} )^4(\frac{1}{3})$$ $$P(X=4)=(\frac{2}{3})^4(\frac{1}{3})$$ $$P(X=4)\approx 0.0658$$