# Probability of this

When run, a computer program chooses the word "expensive'' with probability 2/3 and otherwise chooses the word "free''. It then selects a letter uniformly at random from the word it chose and outputs that letter. Given the program outputs "e'', what is the probability that it chose the word "free''?

What I tried : Probability of the word "expensive" is 2/3, so the probability of getting the word "free" is 1/3. So from the word "free" there is 2 "e", so I guess the probability of getting the letter "e" is 1/2.

The answer that I got is 5/6, which I don't think so its correct. I need some help on this

• This is a question of conditional probability. ''So from the word "free" there is 2 "e", so I guess the probability of getting the letter "e" is 1/2.'' but e is also present in expensive, thus you have to make cases
– user1012971
Commented Jun 2, 2022 at 5:52
• @RamanujanXXV Oh, I misread the question, Thanks for pointing it out !
– Ben
Commented Jun 2, 2022 at 5:54

We can use Bayes Theorem to solve this question. Let $$X$$ be the random variable that outputs the word $$(\text{expensive/free})$$ and let $$L$$ be the random variable that outputs the letter. We are trying to calculate $$P(X=\text{free}|L=\text{e})$$. Using Bayes Theorem: \begin{align} P(X=\text{free}|L=\text{e}) &= \dfrac{P(X=\text{free})P(L=\text{e}|X=\text{free})}{P(L=\text{e})}\\ &= \dfrac{\frac{1}{3}\times \frac{1}{2}}{\frac{2}{3}\times \frac{3}{9}+\frac{1}{3}\times \frac{1}{2}}\\ &= \dfrac{\frac{1}{6}}{\frac{7}{18}}\\ &=\dfrac{3}{7} \end{align}
$$P(free|e)= \frac{P(free)\cap P(e)}{P(e)}$$ By the total probability theorem,$$P(e) = P(e|free).P(free) + P(e|expensive)P(expensive) = \frac{2}{3} \frac{1}{3} + \frac{1}{3}\frac{2}{4} = \frac{7}{18}$$. Thus $$P(free|e)=\frac{\frac{1}{2}\frac{1}{3}}{\frac{7}{18}}= \frac{3}{7}$$.