Maths Report
Maths Report
Maths Report
Bayes’ Theorem and how it can be applied to estimate the probability of having COVID-
19 more accurately when using Rapid Tests
Sylvester So
Introduction
When I first got this assignment, I was presented with a multitude of topics to write a report
on and could even choose my own topic! However, after doing some basic research and
understanding, no topic caught my eye more than the one with “probability” in it. After
learning more and reading multiple papers on Bayes’ Theorem, it quickly piqued my
interest, and I instantly knew what topic I was choosing.
In the field of probability and statistics, few concepts and theorems hold as much
importance and practicality as the Bayes’ Theorem. The theorem is named after Thomas
Bayes, an 18th-century mathematician, who was the first to develop and apply the basic
Bayesian probability framework, which allowed us to update our beliefs and make educated
decisions in the face of uncertainty. Bayes’ Theorem gives us the new probability of an
event based on any updated and prior information that may be related to that event. It can
also be used to predict how hypothetical factors and changes will change the probability of
an event happening.
Its wide utility is also one of the reasons why it is significant to probability and statistics. The
most common usage of Bayes’ Theorem in real life is its use in medical diagnostics, which
we will be going into more later. Bayes’ Theorem is applied to estimate the probability of a
patient having a disease, given their diagnostic test results, prior knowledge of the
prevalence of such disease and the accuracy of the diagnostic tests. Bayes’ Theorem can
also be applied in industrial contexts, risk assessments, predicting customer behaviours,
Document classification and much more.
In this report, we will delve into the principles and formulas of Bayes’ Theorem and how it
can be applied to estimate the probability of having Covid-19 more accurately when using
Rapid Test Kits.
Planning + Data
First, we have to look at the Formula of Bayes’ Theorem:
P ( B| A ) × P ( A )
P ( A|B )=
P ( B)
This Formula states that the probability of A given B, is equal to the probability of B given A,
times the probability of A, all divided by the probability of B.
The Formula is being used to calculate the probability of A given B, put differently, the
Formula is used to figure out what the probability of a certain event occurring is, given that
we already know that another event occurred.
The Formula came from the general formula for a conditional probability:
P( A ∩ B)
P ( A|B )=
P( B)
We can then swap the formula the other way around and we can get this formula below,
which is still the general formula for a conditional probability:
P( B ∩ A )
P ( B| A )=
P (A )
We can cross out the P(A) on the right side and we end up with
P ( B| A ) × P ( A )=P ( A ∩ B )
After gaining basic knowledge of the Bayes’ Theorem and learning its background
information, I am confident enough to try and apply Bayes’ Theorem to real-life scenarios.
For this assignment, I have chosen to apply it to Covid Rapid Testing, since it is still relevant
to this day, and knowing this information could actually help me and others in real-life. I will
be trying to find the actual probability of having Covid-19 given someone tested positive
using the Covid-19 Rapid Test Kit. According to multiple sources, Covid Rapid Testing Kits
have an accuracy of 80%, meaning if you have Covid-19, it shows that you do with 80%
probability and if you don’t have Covid-19, it shows that you don’t with 80% probability.
Before doing research on this topic, I simply thought 80% was the probability I got Covid-19
if I tested positive, which I later found out is totally false. At the time I checked (9/10/2023)
on worldometers, there are 696,314,799 Covid-19 cases in total and a total population of
8,065,379,648. We can divide the number of Covid-19 cases by the total population:
696,314,799/8,065,379,648
=0.0863337…
≈0.0863
That tells us excluding exterior and environmental factors, the probability of anyone getting
Covid is 8.63%
Analysis
Finding False Positives
Gathering information from above, we can put multiple values into variables.
P ( Getting Covid−19 ) =8.63 %=P ( A )
P ( Getting Tested Positive ) =P (B)
P ( Testing Positive Given You Have Covid )=80 %=P(B∨A )
We still do not have P(B), which is the probability of getting tested positive. To find P(B), we
have to use the law of total probability, which can find P(B) by considering the probability of
two mutually exclusive events, in this case P(A), P(Not A) and P(B|A), P(B|Not A). We can
use this formula with P(B) as the subject:
P ( B )=P ( B| A ) × P ( A ) + P ( B|Not A ) × P(Not A)
We need to find P(B|Not A), which is the probability of testing positive given you do not
have Covid-19, which is 20%. We also need to find P(Not A), which is 1-P(A)=0.9137. After
substituting the values into the formula:
There is also an alternative way to find P(B), which is making a table with a population of
10,000 and simulating the numbers in the table. We can first fill in the squares in blue, as we
know the probability of getting Covid-19, We can then use the accuracy of the test (80%) to
find the values of the other squares, 863 X 80% = 690.4 9,137 X 80% = 7,309.6. We can
then fill in the rest of the numbers easily and get all the values on the table.
We can find P(B) by dividing the number of people who Tested Positive by the total
population on the graph: 2517.8 ÷ 10,000 = 0.25178. This method gives us the same value
for P(B) as the value we got from using the law of total probability, which further confirms
P(B). Although it takes more time and effort, I find making a table makes everything a lot
more organised and it allows us to better visualise the probability for different events.
Now we have all the values needed for Bayes’ Theorem, we just have to substitute all the
values and Let P(A|B) as the subject, since we are trying to find the probability of someone
having Covid-19 (P(A)) given that they tested positive(P(B)).
P ( B| A ) × P ( A ) 80 % × 8.63 %
P ( A|B )= P ( A|B )= P ( A|B )=0.27420
P(B) 0.25178
Using Bayes’ Theorem, we are able to find the updated probability of having Covid-19 if you
tested positive, which is roughly 27.42%. This is both surprising and fascinating to me since
the actual probability of having Covid-19 if you tested positive is much lower than the 80%
chance of getting Covid-19 I thought was correct before learning about this topic. However,
the calculations are a representation of Covid-19 being distributed uniformly, and since the
chance of getting Covid-19 can be affected by many different factors, the probability above
can only act as a reference and the value will vary with different environments.
We can also figure out P(C|A) which is the probability of testing negative given you have
Covid-19. Since the test can detect 80% of the people with Covid-19,
P ( C| A )=20 %
We are missing the values of P(C), which we can use the same methods above to find the
value for.
Law of Total Probability:
P ( C ) =P ( C| A ) × P ( A ) + P ( C|Not A ) × P ( Not A)
This time we are missing P(C|Not A) which is the probability of someone testing negative,
given they do not have Covid-19, which is 80%.
P ( C| A ) × P( A) 20 % ×8.63 %
P ( A|C )= P ( A|C )= P ( A|C ) ≈ 0.023068
P(C ) 0.74822
Using Bayes’ Theorem, we can see that the probability of having Covid-19 given the Rapid
Test is negative is 2.3068%, which is a lower than the chance of the Test Kit not working
(20%).
Limitations
Even though this method can be used in a wide range of scenarios, it has some major
limitations. The main one is needing an accurate prior probability of an event. Without this
prior probability, calculating the updated probability would be impossible and Bayes’
Theorem won’t be applied here. Another limitation is the hinderance of accuracy due to
unaccounted factors. When applying Bayes’ Theorem in real life, where there are many
factors to many things, just using Bayes’ Theorem can only result in an estimate of a
conditional event. However, the real world is constantly being affected by many factors,
therefore, it is hard to prevent these inaccuracies.
Conclusion
I first chose this topic since I find myself doing well when dealing with statistical numbers
instead of the other graphing and modelling topics. I also loved how probability is able to
put a number on basically all real-life scenarios, giving us data to base our decisions on.
However, after doing research about probability in general and Bayes’ Theorem, I found out
probability and statistics are a deep field of mathematics which isn’t as easy as I thought and
have a lot of real-world applications. The theorem’s origin and its vast usage also piqued my
interest and motivated me to do more research on the topic. Using real-life data, I have
successfully found the actual probability of false positives and false negatives of the Covid-
19 Rapid Testing Kit. Although the values are only for reference and can be affected by a lot
more different factors in real life, it can give us an estimate of your actual probability after
receiving your Covid-19 test results. Overall, the process went smoothly but I got stuck on
finding P(B) and P(C), I first came up with making a table which worked, but then stumbled
upon the law of total probability, which was way more convenient and easier to use. At first,
I also didn’t understand the theorem at all, but after looking at multiple YouTube videos and
papers on their usages and applications, I was confident enough to start writing out this
report and apply it myself. Besides those setbacks, I felt accomplished in my findings and
enjoyed the process of it.
Bibliography
4, D. (2006, December 4). What is Bayes’s theorem, and how can it be used to assign
probabilities to questions such as the existence of god? what scientific value does it
have? Scientific American. https://www.scientificamerican.com/article/what-is-bayess-
theorem-an/
Encyclopædia Britannica, inc. (2023, August 17). Bayes’s theorem. Encyclopædia Britannica.
https://www.britannica.com/topic/Bayess-theorem
Rachael Zimlich, B. (2023, August 2). Are at-home covid-19 tests accurate?. Verywell
Health. https://www.verywellhealth.com/are-at-home-covid-tests-accurate-enough-
5210762
The role of probability. Bayes’s Theorem. (n.d.). https://sphweb.bumc.bu.edu/otlt/mph-
modules/bs/bs704_probability/bs704_probability6.html
Wikimedia Foundation. (2023a, May 21). Covid-19 rapid antigen test. Wikipedia.
https://en.wikipedia.org/wiki/COVID-19_rapid_antigen_test