Following MacKay Chapter 2:
The frequencies of all $27^2$ 2-letter bigrams $xy$ in the Linux FAQ, from MacKay Ch. 2.
${\rm Pr}(x,y)\;={\rm Pr}(x|y)\;{\rm Pr}(y)$
${\rm Pr}(x,y)\;={\rm Pr}(y|x)\;{\rm Pr}(x)$
The conditional probabilities for bigrams $xy$ in the Linux FAQ, from MacKay Ch. 2. The one on the left helps answer the question: which letter is likely to come next?
Q: What additional information do you need to turn the joint distribution above into these figures?
${\rm Pr}(x) = \sum_y\;{\rm Pr}(x,y)$
${\rm Pr}(x) = \int\;{\rm Pr}(x,y)\;dy$
$\int\;{\rm Pr}(x,y)\;dx\,dy = 1$
${\rm Pr}(x,y\,|\,H)\;={\rm Pr}(x\,|\,y,H)\;{\rm Pr}(y\,|\,H)$
In everyday life we use words like "probability," "chances", "odds" and so on all the time to describe our belief in things.
Here's an example, due to poet and educator Hilaire Belloc:
Discuss degree of belief and quantifiable probability with your neighbor, and see if you can come up with an example. Whose beliefs are involved, and how is the probability quantified? Can you distinguish between a probability that is equal to a frequency, and a probability that describes a degree of belief, in your scenario?
$B(x)$ can be mapped onto, and indeed replaced by, probability ${\rm Pr}(x)$ if the Cox Axioms are satisfied. As a checklist, these are:
If your degree of belief $B(x)$ is greater than your degree of belief $B(y)$, and your degree of belief $B(y)$ is greater than your degree of belief $B(z)$, is $B(x)$ greater than $B(z)$? Yes: this means that degree of belief can be represented by numbers
Is degree of belief $B(x)$ related to $B(NOT x)$? Yes: one goes up as the other goes down, like probabilities.
Does your degree of belief in both $x$ and $y$ depend on the degree of belief in $y$ and the degree of belief in $x$ given $y$?
${\rm Pr}(x|d,H)\;=\frac{1}{Z}{\rm Pr}(d|x,H)\;{\rm Pr}(x|H)$
where $Z$ is a normalization factor given by
$Z = \int {\rm Pr}(d|x,H)\;{\rm Pr}(x|H)\;dx = {\rm Pr}(d|H)$
${\rm Pr}(H|d)\;=\;{\rm Pr}(d|H)\;{\rm Pr}(H)\;/\;{\rm Pr}(d)$
You go to the doctor to be tested for a rare disease, and the test comes back positive.
The test is pretty good: it has a 95% true positive rate, and a 10% false positive rate. The incidence of the disease in the general population is 1 in 5000.
What is the probability that you actually have the disease? Are your chances of being sick better or worse than 95%?
Let's edit the code below and compute this posterior probability using Bayes Theorem.
In [20]:
P_testpositive_given_sick = 0.95
P_testpositive_given_healthy = 0.10
P_sick = 1.0/5000.0
P_healthy = 1 - P_sick
Z = P_testpositive_given_sick*P_sick + \
P_testpositive_given_healthy*P_healthy
P_sick_given_testpositive = P_testpositive_given_sick*P_sick / Z
print("Probability of actually having the disease: ",round(P_sick_given_testpositive,3)*100,"%")
In this example, the prior probability of having the disease is so low that it takes a much better test to raise your chances of having the disease above 5%. Try changing the test quality each way (reduce the flase positive rate or increase the true positive rate) and see how good it really needs to be.
Now let's go back to the Xray Image
In [ ]: