How do I formalize this? And how do I calculate using the Bayes formula?
In the land of Pai, 3% of the population has a rare disease called Coditis. There is a test to test for Coditis: 18% of the population test positive on this test. The test is not that reliable: if someone that actually has Coditis gets tested, they only have a 60% chance of testing positive.
a) What is the chance of having Coditis if a citizen of Pai tests positive?
b) What is the chance of testing positive given that the citizen does not have Coditis?
For part (a) you want prob of having the disease, given you tested positive. You want this to be represented by $P(A|B)$ (which is on the LHS of the equation by itself). So let $A$ represent the event of having the disease, and $B$ is the event that you tested positive for it. Then look at the RHS of the equation.
$$P(A|B)=\frac{P(B|A)P(A)}{P(B)}$$
$P(B|A)$ is the ptobability of testing positive if you have the disease (this is given in the question).
$P(A)$ is the probability of having the disease, which is given by the occurrence rate in the population.
$P(B)$ is the prob of testing positive which is the fraction of the population that tested positive.
All of this info is given in the question, then simply combine using the formula to get $P(A|B)$.
Part (b) asks you to find $P(B|\neg A)$, for which you actually need the Law of total probability. I will give you a chance to figure out the details.