Probability of k heads given a biased coin, unknown bias There are two biased coins, the probability of flipping heads for the first coin is a, the probability of flipping heads for the second coin is b. One of the coins is chosen at random, with probability p that the first coin is chosen. A Once the coin is chosen, it is flipped 3 times and k Heads are observed, where k = 0, 1, 2, 3. 
What is the conditional probability that the first coin was chosen? 
Letting X be the random variable representing the choice of the coin, and K be the random variable representing the number of heads, I understand that this is an application of a variation of Bayes' Rule: 
$$
p_{X|K}(x|k) = \frac {p_X(x)p_{K|X}(k|x)}{\sum_{k'}p_X(x')p_{K|X}(k|x')}
$$
I know that the first term is substituted for p, from above: $$ p_X(x) = p $$
But I'm unsure how to evaluate: $$ p_{K|X}(k|x) $$
Having similar trouble interpreting the denominator. 
Any help is much appreciated. Picking up a stat class late in the semester and struggling to get caught up. Thanks in advance. 
 A: Conditional on the first coin being chosen, the probability of flipping $k$ heads is $\binom{3}{k}a^k(1-a)^{3-k}$, and conditional on the second coin being chosen, it is $\binom{3}{k}b^k(1-b)^{3-k}$. Thus, by Bayes' Rule, the probability of flipping $k$ heads is
$$
p\binom{3}{k}a^k(1-a)^{3-k}+(1-p)\binom{3}{k}b^k(1-b)^{3-k}.
$$
Thus, the conditional probability that the first coin was chosen given that $k$ heads were flipped is
$$
\frac{p\binom{3}{k}a^k(1-a)^{3-k}}{p\binom{3}{k}a^k(1-a)^{3-k}+(1-p)\binom{3}{k}b^k(1-b)^{3-k}}.
$$
A: Given $X$, that is given the probability of heads, the distribution of $K$ is binomial:
$$p_{K|X}(k|1)=\binom{3}{k}a^k(1-a)^{3-k}$$
$$p_{K|X}(k|2)=\binom{3}{k}b^k(1-b)^{3-k}$$
A: Using your $X$ and your $K$, I will let $X = 1$ denote the event that the first coin was chosen and $X=0$ be the event that the second coin was chosen.
Then the problem is
\begin{align*}
P(X=1|K = k) &=\frac{P(X=1,K=k)}{P(K = k)}\\
&=\frac{P(K = k|X = 1)P(X=1)}{P(K = k, X = 0)+P(K=k, X = 1)}\\
&=\frac{P(K = k|X = 1)P(X=1)}{P(K = k|X=0)P(X = 0)+P(K=k| X = 1)P(X=1)}\\
&=\frac{\binom{3}{k}a^k(1-a)^{3-k}\cdot p}{\binom{3}{k}b^k(1-b)^{3-k}\cdot(1-p)+\binom{3}{k}a^k(1-a)^{3-k}\cdot p}
\end{align*}
wherein I notice that $K|X=1$ follows a binomial distribution with $n = 3$ and probability of success $a$; $K|X=0$ follows a binomial distribution with $n = 3$ and probability of success $b$; and in the denominator of the second line, I used the law of total probability.
