# Calculate the maximum a posteriori estimate

I'm new to this site and was wondering if anyone could shed any light on maximum posteriori hypothesis for me. I know that the formula is:

$\hat{h}_{MAP} = \text{argmax}_h \; \; p(D|h)p(h)$

I know that $P(D|h)$ stands for the probability of $D$ given $h$ and that $p(h)$ is the prior probability of hypothesis $h$.

Here's the example that I'm trying to work through:

When a test for cancer is given to patients, 98.5% of the patients who have the disease test positive and 9.5% of the patients who do not have the disease test positive. Suppose that 8% of patients have the disease. What is the maximum a posteriori hypothesis for a patient who tests positive?

• Welcome to CV! I've answered your question in the spirit of our self-study tag, which you may want to add to your question. – Sean Easter Mar 7 '17 at 16:02

Consider these facts in order, and you should be able to work out the answer:

• Taking $\arg \max_{h} p(D|h)p(h)$ means finding $h$ that maximizes $p(D|h)p(h)$
• You have two hypotheses to consider: Cancer, and not. The 8% mentioned in the problem gives you $p(h)$ for both $p(h_{cancer})$ and $p(h_{\neg cancer})$.
• Likewise, the 98.5% and 9.5% can give you $p(D = +|h_{cancer})$ and $p(D = + |h_{\neg cancer})$

I think your confusion may be coming from the terms. I feel following explanation helpful, not sure if it also applies to you.

• $P(h)$ means probability of hypothesis (prior), in your cancer example, it means in all human, the probability of getting cancer. The numbers are

$$P(h=1)=0.8$$ $$P(h=0)=1-0.8$$

• $P(D|h)$ means the probability of getting specific data given the hypothesis (likelihood), in your cancer example, it means how the test would behave for a cancer / non-cancer people. The numbers are

$$P(D=1|h=1)=0.985$$ $$P(D=0|h=1)=1-0.985$$ $$P(D=1|h=0)=0.095$$ $$P(D=0|h=0)=1-0.095$$

The question seems to be a homework and I will not complete all for you. Can you start from here?

• Hi, @hxd1011. This is not homework; however, it did appear in the end of the chapter problems for the textbook I am using. I am preparing for an exam and was working through the examples. Thanks anyway. – Johnny Mar 7 '17 at 20:32