Bayes Theorem confusion... (more complex) (a)A gambler has a fair coin and a two-headed
coin in his pocket. He selects one of the coins
at random; when he flips it, it shows heads.
What is the probability that it is the fair coin?
(b) Suppose that he flips the same coin a second
time and, again, it shows heads. Now what is
the probability that it is the fair coin?
answer to (a) is 1/3 which you need for (b),
the answer to (b) is 

I learned the basics of Bayes, but I don't understand what it means to have $O_1$ and $O_2$
Problem (c))
Suppose that he fluids the same coin a third time and it shows tails. What's the probability that it is the fair coin?
How do we solve this?
 A: It appears that $O_1$ and $O_2$ are first outcome is heads and second outcome is heads. $P(F|O_1)$ is the probability that the coin is fair given that it comes up heads the first time is $1/3$, and the probability that it comes up heads the second time given that it is the fair coin and came up heads the first time is $1/2$. You can check that the numbers in the denominator are also consistent with this interpretation of $O_1$ and $O_2$.
A: We can simplify the problem to: given we got two heads in a row, what is the probability it is the fair coin? 
So let $R$ be the event "two heads in a row" and $F$ the event "fair coin." We want $\Pr(F|R)$. We have
$$\Pr(F|R)=\frac{\Pr(F\cap R)}{\Pr(R)}.$$
The analysis is now standard. (i) The probability we chose the fair coin is $\dfrac{1}{2}$. Given we chose the fair coin, the probability of two heads in a row is $\dfrac{1}{4}$. So $\Pr(F\cap R)=\dfrac{1}{2}\cdot\dfrac{1}{4}=\dfrac{1}{8}$.
(ii) The probability that we chose the two-headed coin is $\dfrac{1}{2}$. Given that it is two-headed, the probability of $R$ is $1$. 
Thus $\Pr(R)=\dfrac{1}{2}\cdot\dfrac{1}{4}+\dfrac{1}{2}\cdot 1=\dfrac{5}{8}$.
Now divide. The required conditional probability $\Pr(F|R)$ simplifies to $\dfrac{1}{5}$.
A: I like doing it with tables, like here.
You first put your hypothesis into the columns

The column entries say the expected distribution of observations (I guess that O stands for "Observation" in your question), where it may take heads or tails values/events. The priors .5 are given to every hypothesis (coin fariness). 
Result are read from third table

where rows show distribution of hypothesis given observation. You say that heads is observed -- read first row. 
We can add more rows

and see that fair under two heads observation is 1/5 since it is the value in the fair in the hh row in the table 3

In your formula, however, instead of making two observations under assumption of equal priors .5/.5, you make a single (second) observation with priors 1/3 and 2/3 that you have got from the first experiment. Enter the values

You see, you have got .2 again in the last table. 
The algorithm first converts the column distribution of the first table into the intermediate, joint distirbution by multiplying every first table entry with the coumn weight (bayesian call it column or hypothesis "prior"). This step correpsonds to the nominator of your formula. 
In the second step, it makes the row distribution by dividing the row entries with the row totals, which correponds to the denominator of your formula. We can go back to the joint distribution if multiply the row entries with the row margins. 
Effectively, first table allows you to focus on desired hypothesis (what is observation distribution given column-hypothesis is true), second table gives joint distribution you should be aware of and third table allows you to focus on desired observation (a row) and consider what are the hypothesis probabilities, given that obswervation $O_n$.
