Q: Probability question about panda births and statistical tests I am self-learning statistics, and I have a question about how to do the following problem: 

There are two species of panda bear, A and B. Both are equally common in the wild and live in the same places. A veterinarian has a new genetic test that can identify the species of a panda. But the test, like all tests, is imperfect. This is the information you have about the test:
• The probability it correctly identifies a species A panda is 0.8. 
• The probability it correctly identifies a species B panda is 0.65.
The vet administers the test to your panda and tells you that the test is positive for species A. Compute the posterior probability that your panda is species A. 

I wish to calculate P(species=A | test=A), by using the Bayes theorem and calculate the prior, P(test=A). 
I am confused about the test on species B. How to calculate the prior? 

A: Bayes' theorem gives
\begin{equation}
\mathrm{prob}(\mathrm{species} = A | \mathrm{test} = A, \mathcal{I}) = \frac{\mathrm{prob}(\mathrm{test} = A | \mathrm{species} = A, \mathcal{I}) \: \mathrm{prob}(\mathrm{species} = A | \mathcal{I})}{\mathrm{prob}(\mathrm{test} = A | \mathcal{I})}
\end{equation}
with $\mathcal{I}$ being the problem information. By the marginalisation and product rules we can expand the denominator as
\begin{align}
\mathrm{prob}(\mathrm{test} = A | \mathcal{I})
&= \sum_{s \in \{A, B\}} \mathrm{prob}(\mathrm{test} = A, \mathrm{species} = s | \mathcal{I}) \\
&= \sum_{s \in \{A, B\}} \mathrm{prob}(\mathrm{test} = A | \mathrm{species} = s, \mathcal{I}) \: \mathrm{prob}(\mathrm{species} = s | \mathcal{I})
\end{align}
From the problem information we have
\begin{align}
\mathrm{prob}(\mathrm{test} = A | \mathrm{species} = A, \mathcal{I}) &= 0.8 \\
\mathrm{prob}(\mathrm{test} = B | \mathrm{species} = B, \mathcal{I}) &= 0.65 \\
\mathrm{prob}(\mathrm{species} = A | \mathcal{I}) &= 0.5 \\
\mathrm{prob}(\mathrm{species} = B | \mathcal{I}) &= 0.5
\end{align}
and from the second line
\begin{equation}
\mathrm{prob}(\mathrm{test} = A | \mathrm{species} = B, \mathcal{I}) = 0.35
\end{equation}
So the answer is
\begin{align}
\mathrm{prob}(\mathrm{species} = A | \mathrm{test} = A, \mathcal{I})
&= \frac{0.8 \cdot 0.5}{0.8 \cdot 0.5 + 0.35 \cdot 0.5} \\
&= \frac{16}{23} \simeq 0.696
\end{align}
