Learning starts from a valid question.
Presently let this be for Corona affected related
________________________________
Suppose you saw in some representative sample 10 people are suffering from Corona and 200 have
no Corona.
The above is actually not easy to find.
This comes from observation, experience, some sort of frequency of disease in the population.
So the question is
------------------
Can we say that I have (10/200+10) or (1/21) chance to get caught by Corona.
Hold on!
--------------------------------
You go for a medical test to know this.
The test can either report positive or negative.
Are these positive and negative results always correct??? Guess, why??
Here tests positive does not means the person has the disease or all those who are affected with
corona may not get a test positive, why?
Because medical tests are always statistical, may not be 100 percent accurate.
Suppose from the medical record you found,
Out of those 10 who are affected, only 4 got a positive test report.
Also out of those 200 unaffected, 20 got a positive test report.
________________________________
Now time to ask a valid question
You know 10 out of 210 are actually affected (Just an initial condition)
As we know this is extremely difficult to find a specific value.
Only from some prior belief/ or past data/ or frequency of disease,
We come up with such number. May not be very realistic
So get a realistic value we started exploring the scenario through some realistic situation.
In this situation more realistically we would like to know,
How many are actually affected given their medical test come to be positive.
Here the sequence of events are like
You found the percentage affected in the sample. You go for a test.
You want to find out what the chance of being affected if tested positive.
______________________
Or easier version of putting it.
What is percentage affected (prior probability)
What is percentage affected given tested positive. (Posterior Probability)
_____________________
So basically here updating the affected percentage by knowing more data (in this case knowing test
results)
Suppose we want to predict the chance of being affected for a new person in this scenario
So the hypothesis (H) is THE PERSON IS AFFECTED
The person test result comes positive, let call this as Evidence (E)
We need to find the person is affected given test is positive or (H/E)
--------------------------------------------------------------------
We know p(H). This is the prior probability (Or probability that the Hypothesis - THE PERSON IS
AFFECTED).
We want to know p(H/E). This is the posterior probability (Or the probability that the THE PERSON IS
AFFECTED given THE TEST IS POSITIVE)
Very important to understand further. So keep a note of this in mind.
--------------------------------------------------------------------
Here Baye's theory comes to help.
p(H) * p(E/H)
p(H/E) = ------------------------
p(E)
Since the known condition or evidence is THE TEST IS POSITIVE,
The denominator should include all instances of positive (or in probability language :- probability of
testing positive)
Now that testing positive or p(E) can include two conditions, Or in probability language include all
possible sample space-
i) A person affected and tested +ve among those affected
p(H) * p(E/H)
ii)A person not affected and tested +ve among those not affected
p(~H) * p(E/~H)
So using this two sub components of testing positive we can write p(E) as
p(E) = p(H) * p(E/H) + p(~H) * p(E/~H)
Plugging this p(E) in the expression above
p(H) * p(E/H)
p(H/E) = ------------------------
p(H) * p(E/H) + p(~H) * p(E/~H)
So this is how we use the formula for Bayes theorom
-------------------------------------------------------------------
Now let us use our example for finding p(H/E)
Let us focus on calculating p(E) first.
p(E) = p(H) * p(E/H) + p(~H) * p(E/~H)
In probability terms
i) first bit is person affected (1/21)
tested positive (4/10)
ii)second bit is person not affected (200/210)
tested positive (20/200)
So now we can calculate the p(H/E) plugging all those values as
(1/21) * (4/10)
p(H/E) = ------------------------------------------ = 1/6 or 16.7 %
(1/21) * (4/10) + (200/210) * (20/200)
So THE PERSON IS AFFECTED given THE TEST IS POSITIVE have a chance of 1/6
This is posterior probability, the most important deduction of Mathematician Bayes.
________________________________
Take a break and come back after 5 mins
________________________________
Even the problem sees bit realistic, the posterior probability of 1/6 seems very low. It essentially
implies that if someone tests positive the actual chance of her being affected is only 1/6 or 16.7 %.
So it’s possible that the doubt arise because of the above low result.
So let the person went to another lab and get tested again for the virus. Suppose the person get
positive result in the second test also.
Now it may be a good idea to find out what could be the actual chance of the person being affected
given the second time also the person tested positive.
How should we proceed here. any guess???
You only need to change some values in the above Bayesian formula for calculating p(H/E)
Ok... It goes like this.
Let me write the formula again or even by this time you have remembered.
p(H) * p(E/H)
p(H/E) = ------------------------------------------
p(H) * p(E/H) + p(~H) * p(E/~H)
We know p(H) is probability of affected, which was initially 1/21
However now there is some updated information.
Just recently we found the probability of affected given a person tested positive is 1/6
so let us update this information but how? guess......
This value of 1/6 now becomes the new value of probability of affected- p(H)
So in above formula p(H) = 1/6
then p(~H) = 5/6
Other values keep as it is.
(1/6) * (4/10)
So p(H/E) = ----------------------------------- = 0.44 or 44 %
(1/6) * (4/10) + (5/6) * (20/200)
So here we are updating the prior probability and also getting updated posterior probability.
Now the chance of the person being affected is 44% instead of 16.7% which was earlier.
Like this one can keep on updating the prior and posterior probabilities to solve real world problems.