Bayes’ theorem, or sometimes called Bayes’ rule, is one of the important theorems that provides a strong foundation for probability theory. As its name suggests, the theorem is named after its discoverer, **Thomas Bayes** (1701–1761), who was a British statistician. Interestingly, Bayes never published his major work during his lifetime. However, **Richard Price** (1723–1791), a British mathematician, edited Bayes’ surviving notes and officially published them in 1763, naming it Bayes’ rule as a final tribute to Bayes.

Bayes’ rule is built upon the concept of partitioning within a set. Consider the following Venn diagram.

The Venn diagram above shows that event $A$ can be expressed as the union of two mutually exclusive events, namely $E \cap A$ and $E^c \cap A.$ In other words,

$$A = (E \cap A) \cup (E^c \cap A).$$If we relate this fact to the concept of probability, we can derive

$$\begin{aligned} p(A) & = P ((E \cap A) \cup (E^c \cap A)) \\ & = p(E \cap A) + p(E^c \cap A) \\ & = p(E) \cdot p(A \mid E) + p(E^c) \cdot p(A \mid E^c). \end{aligned}$$With this initial idea, we can generalize the case by partitioning the sample space into $k$ disjoint subsets, which is then expressed in the **theorem of total probability** or often known as the law of total probability.

**Theorem of Total Probability**

If events $B_1, B_2, \cdots, B_k$ form a partition of the sample space $S$ such that $p(B_i) \ne 0$ for $i \in \{1, 2, \cdots, k\},$ then for any event $A$ in $S,$ it holds that

$$p(A) = \displaystyle \sum_{i=1}^k p(B_i \cap A) = \sum_{i=1}^k p(B_i) \cdot p(A \mid B_i).$$

By using the theorem of total probability, Bayes’ rule can then be expressed based on the definition of conditional probability, i.e., in cases where we want to find the value of $p(B_i \mid A).$

**Bayes’ Theorem**

If events $B_1, B_2, \cdots, B_k$ form a partition of the sample space $S$ such that $p(B_i) \ne 0$ for $i \in \{1, 2, \cdots, k\},$ then for any event $A$ in $S$ with $p(A) \neq 0,$ it holds that

$$p(B_r \mid A) = \dfrac{p(B_r \cap A)}{\displaystyle \sum_{i=1}^k p(B_i \cap A)} = \dfrac{p(B_r) \cdot p(A \mid B_r)}{\displaystyle \sum_{i=1}^k p(B_i) \cdot p(A \mid B_i)}$$for $r \in \{1, 2, \cdots, k\}.$

Using the definition of conditional probability, it is known that

$$p(B_r \mid A) = \dfrac{p(B_r \cap A)}{p(A)},$$and using the theorem of total probability related to $p(A),$ we obtain

$$p(B_r \mid A) = \dfrac{p(B_r \cap A)}{\displaystyle \sum_{i=1}^k p(B_i \cap A)} = \dfrac{p(B_r) \cdot p(A \mid B_r)}{\displaystyle \sum_{i=1}^k p(B_i) \cdot p(A \mid B_i)}.$$ $\blacksquare$

**Note:**Rounding, indicated by the symbol $\approx$, is performed to 4 (four) decimal places, unless specific instructions have been given.

This article was written based on various sources, including English-language references. Two sources used include the book “**Discrete Mathematics and Its Applications**” by **Kenneth H. Rosen** and the book “**Probability & Statistics for Engineers & Scientists**” by **Ronald E. Walpole, et al.**

Below, a number of example problems and solutions on Bayes’ theorem have been provided. Some of the example problems were created by the author, and others were adapted from the literature.

**Baca Juga: Materi, Soal, dan Pembahasan – Peluang Bersyarat**

**Quote by James Cameron**

**Question Type: Essay**

**Problem Number 1**

A factory uses three types of machines, $B_1, B_2,$ and $B_3,$ to produce products in proportions of $30\%, 45\%,$ and $25\%$ respectively. Past experience shows that $2\%, 3\%,$ and $2\%$ of the products processed by each machine, in order, are defective. Assuming a finished product is randomly selected, what is the probability that the selected product is defective?

Let $A$ be the event of selecting a defective product, and let $B_1, B_2,$ and $B_3$ be the events that a product is processed by machine $B_1, B_2,$ and $B_3$ respectively. From this, we know the following information:

$$\begin{aligned} p(B_1) & = 30\% = 0.30 \\ p(B_2) & = 45\% = 0.45 \\ p(B_3) & = 25\% = 0.25 \\ p(A \mid B_1) & = 2\% = 0.02 \\ p(A \mid B_2) & = 3\% = 0.03 \\ p(A \mid B_3) & = 2\% = 0.02 \end{aligned}$$Using the theorem of total probability, we will find the value of $p(A),$ which is

$$\begin{aligned} p(A) & = \displaystyle \sum_{i=1}^3 p(B_i) \cdot p(A \mid B_i) \\ & = (0.30)(0.02) + (0.45)(0.03) + (0.25)(0.02) \\ & = 0.006 + 0.0135 + 0.005 \\ & = 0.0245. \end{aligned}$$So, the probability that the selected product is defective is $\boxed{0.0245}.$

**Baca Juga: Soal dan Pembahasan – Peluang (Tingkat SMP/Sederajat)**

**Problem Number 2**

Given that the global population ratio of males to females is $101:100.$ On the other hand, $80\%$ of females wear pink clothes, while $25\%$ of males wear pink clothes. At a certain point, a man is talking to someone wearing pink. What is the probability that the person he is talking to is a woman?

Let $L$ and $P$ respectively denote the events that the person the man is talking to is male and female. Let $M$ denote the event that the person is wearing pink. From this, the following information is known:

$$\begin{aligned} p(L) & = \dfrac{101}{101+100} = \dfrac{101}{201} \\ p(P) & = \dfrac{100}{101+100} = \dfrac{100}{201} \\ p(M \mid P) & = 80\% = \dfrac{4}{5} \\ p(M \mid L) & = 25\% = \dfrac{1}{4}. \end{aligned}$$Using Bayes’ rule, we will find the value of $p(P \mid M),$ which is

$$\begin{aligned} p(P \mid M) & = \dfrac{p(M \mid P) \cdot p(P)}{p(M)} \\ & = \dfrac{p(M \mid P) \cdot p(P)}{p(M \mid P) \cdot p(P) + p(M \mid L) \cdot p(L)} \\ & = \dfrac{\dfrac{4}{5} \cdot \dfrac{100}{201}}{\dfrac{4}{5} \cdot \dfrac{100}{201} + \dfrac{1}{4} \cdot \dfrac{101}{201}} \\ & = \dfrac{320}{421}. \end{aligned}$$So, the probability that the person wearing pink whom the man is talking to is a woman is $\boxed{\dfrac{320}{421}}.$

**Problem Number 3**

A total of $0.1\%$ of the global beetle population belongs to a rare subspecies that typically has a specific pattern on its back. Specifically, $98\%$ of this beetle subspecies has the pattern. However, entomologists have also found that some common beetles also have this pattern. Overall, $5\%$ of all beetles have this pattern on their back.

If an entomologist finds a beetle with this pattern on its back, what is the probability that the beetle belongs to the rare subspecies?

Let $L$ and $P$ respectively denote the events of finding a beetle that belongs to the rare subspecies and finding a beetle with the pattern on its back. From this, the following information is known:

$$\begin{aligned} p(L) & = 0.1\% = 0.001 \\ p(P \mid L) & = 98\% = 0.98 \\ p(P) & = 5\% = 0.05 \end{aligned}$$sing Bayes’ rule, we will find the value of $p(L \mid P),$ which is

$$\begin{aligned} p(L \mid P) & = \dfrac{p(P \mid L) \cdot p(L)}{p(P)} \\ & = \dfrac{0.98 \cdot 0.001}{0.05} \\ & = 0.0196. \end{aligned}$$So, the probability that the beetle belongs to the rare subspecies is $\boxed{0.0196}$ or $1.96\%$. In other words, if we find a beetle with this pattern on its back, there is only a $1.96\%$ chance that it belongs to the rare subspecies.

**Baca Juga: Soal dan Pembahasan – Peluang dan Kombinatorika (Tingkat SMA)**

**Problem Number 4**

Assume that there are four inspectors, denoted as $A, B, C,$ and $D$, assigned to put labels on customer packages. Inspector $A$ labels $20\%$ of the total packages carelessly, resulting in $1$ out of $200$ packages being unlabeled. Inspector $B$ labels $60\%$ but misses $1$ out of $100$ packages. Inspector $C$ labels $15\%$ but misses $1$ out of $50$ packages. Inspector $D$ labels $5\%$ but misses $1$ out of $200$ packages. If a customer complains that their package is unlabeled, what is the probability that inspector $A$ should have labeled it?

Let $X$ be the event that a package is unlabeled. Let $Y_1, Y_2, Y_3,$ and $Y_4$ respectively be the events that inspectors $A, B, C,$ and $D$ label a given package.

From this, we know the following information:

$$\begin{aligned} p(Y_1) & = 20\% = 0.20 \\ p(Y_2) & = 60\% = 0.60 \\ p(Y_3) & = 15\% = 0.15 \\ p(Y_4) & = 5\% = 0.05 \\ p(X \mid Y_1) & = \dfrac{1}{200} = 0.005 \\ p(X \mid Y_2) & = \dfrac{1}{100} = 0.010 \\ p(X \mid Y_3) & = \dfrac{1}{50} = 0.020 \\ p(X \mid Y_4) & = \dfrac{1}{200} = 0.005 \\ \end{aligned}$$Using Bayes’ rule, we will find the value of $p(Y_1 \mid X),$ which is

$$\begin{aligned} p(Y_1 \mid X) & = \dfrac{p(X \mid Y_1) \cdot p(Y_1)}{p(X \mid Y_1) \cdot p(Y_1) + p(X \mid Y_2) \cdot p(Y_2) + p(X \mid Y_3) \cdot p(Y_3) + p(X \mid Y_4) \cdot p(Y_4)} \\ & = \dfrac{0.005 \cdot 0.20}{0.005 \cdot 0.20 + 0.010 \cdot 0.60 + 0.020 \cdot 0.15 + 0.005 \cdot 0.05} \\ & \approx 0.0976. \end{aligned}$$So, the probability that the package should have been labeled by inspector $A$ is approximately $\boxed{0.0976}.$

**Problem Number 5**

The police department in a certain area plans to enforce speed limits for motorcyclists using radar traps installed at four different locations. The radar traps at each location $L_1, L_2, L_3,$ and $L_4$ will be operational with probabilities of $40\%,$ $30\%,$ $20\%,$ and $30\%$ at that time. If a speeding motorcyclist has probabilities of $0.2,$ $0.1,$ $0.5,$ and $0.2$ respectively to pass through the four locations, determine:

- the probability that they will receive a speeding ticket;
- the probability that they will pass the radar trap located at $L_2$ after it is known that they received a speeding ticket.

Let $S_1, S_2, S_3,$ and $S_4$ respectively denote the events of a motorcyclist speeding through the four locations. Let $R$ denote the event of a radar trap operating and the motorcyclist receiving a speeding ticket. It is given that:

$$\begin{aligned} p(S_1) & = 0.2 \\ p(S_2) & = 0.1 \\ p(S_3) & = 0.5 \\ p(S_4) & = 0.2 \\ p(R \mid S_1) & = 40\% = 0.4 \\ p(R \mid S_2) & = 30\% = 0.3 \\ p(R \mid S_3) & = 20\% = 0.2 \\ p(R \mid S_4) & = 30\% = 0.3. \end{aligned}$$

**Answer a)**

Using the theorem of total probability, we will find the value of $p(R),$ which is:

$$\begin{aligned} p(R) & = \sum_{i=1}^4 p(R \mid S_i) \cdot p(S_i) \\ & = (0.4)(0.2) + (0.3)(0.1) + (0.2)(0.5) + (0.3)(0.2) \\ & = 0.08 + 0.03 + 0.10 + 0.06 \\ & = 0.27. \end{aligned}$$So, the probability that the motorcyclist will receive a speeding ticket is $\boxed{0.27}$.

**Answer b)**

Using Bayes’ rule, we will find the value of $p(S_2 \mid R),$ which is:

$$\begin{aligned} p(S_2 \mid R) & = \frac{p(S_2 \cap R)}{p(R)} \\ & = \frac{p(R \mid S_2) \cdot p(S_2)}{p(R)} \\ & = \frac{0.3 \cdot 0.1}{0.27} \\ & \approx 0.1111. \end{aligned}$$So, the probability that the motorcyclist will pass the radar trap located at $L_2$ after it is known that they received a speeding ticket is approximately $\boxed{0.1111}$.

**Problem Number 6**

A store sells two types of paint, water-based paint and oil-based paint. Based on long-term sales data, it is known that the probability of a customer buying water-based paint is $0.65.$ Among those customers, $60\%$ also buy a roller. On the other hand, only $30\%$ of customers who buy oil-based paint also buy a roller. If a customer is randomly chosen and it is known that the customer bought both a roller and a can of paint, what is the probability that the paint purchased is water-based paint?

Let $A, A^c,$ and $B$ respectively denote the events of a customer buying water-based paint, oil-based paint, and a roller. From this, the following information is known:

$$\begin{aligned} p(A) & = 0.65 \\ p(A^c) & = 1-p(A) = 0.35 \\ p(B \mid A) & = 60\% = 0.60 \\ p(B \mid A^c) & = 30\% = 0.30\end{aligned}$$Using Bayes’ rule, we will find the value of $p(A \mid B),$ which is

$$\begin{aligned} p(A \mid B) & = \dfrac{p(B \mid A) \cdot p(A)}{p(B \mid A) \cdot p(A) + p(B \mid A^c) \cdot p(A^c)} \\ & = \dfrac{0.60 \cdot 0.65}{0.60 \cdot 0.65 + 0.30 \cdot 0.35} \\ & \approx 0.7879. \end{aligned}$$So, the probability that the paint purchased by the customer is water-based paint is approximately $\boxed{0.7879}$.

**Problem Number 7**

A truth serum has the characteristic that there is a $90\%$ chance that a guilty suspect will indeed be declared guilty, while the remaining $10\%$ will be declared innocent. On the other hand, an innocent suspect is falsely declared guilty with a $1\%$ probability. If a suspect is chosen from a group of suspects, $5\%$ of whom have committed a crime, and the chosen suspect is declared guilty by the truth serum, what is the probability that they are actually innocent?

Let $B$ and $S$ respectively denote the events of a suspect being innocent and guilty of a crime. Let $b$ and $s$ respectively denote the events of a suspect being declared innocent and guilty by the truth serum in a crime.

From this, the following information is known:

$$\begin{aligned} p(B) & = 95\% = 0.95 \\ p(s \mid B) & = 1\% = 0.01 \\ p(S) & = 5\% = 0.05 \\ p(s \mid S) & = 90\% = 0.90 \end{aligned}$$Using Bayes’ rule, we will find the value of $p(B \mid s),$ which is:

$$\begin{aligned} p(B \mid s) & = \dfrac{p(s \mid B) \cdot p(B)}{p(s \mid B) \cdot p(B) + p(s \mid S) \cdot p(S)} \\ & = \dfrac{0.01 \cdot 0.95}{0.01 \cdot 0.95 + 0.90 \cdot 0.05} \\ & \approx 0.1743. \end{aligned}$$So, there is a probability of approximately $17.43\%$ that a suspect declared guilty by the truth serum is actually innocent.

**Baca: Soal dan Pembahasan – Distribusi Peluang Binomial**

**Problem Number 8**

A study concludes that an estimated $0.8\%$ of the population of country $X$ is infected with the human immunodeficiency virus (HIV). Diagnostic tests are then conducted to determine whether someone is infected with the virus or not. Based on data collected over time, $99.99\%$ of those infected with HIV will test positive on the diagnostic test. Additionally, $1.6\%$ of the population tested will receive a positive result.

- If someone is randomly chosen and it is known that they have tested positive on the diagnostic test, determine the probability that they are truly infected with the HIV.
- If someone is randomly chosen and it is known that they have tested negative on the diagnostic test, determine the probability that they are actually infected with the HIV. Express your answer in scientific notation in the form of $a \times 10^b$, where $a$ is a two-digit number after the decimal point.

Let $H$ and $P$ respectively denote the events of someone being infected with the HIV and testing positive on the diagnostic test. We are given $p(H) = 0.008$, $p(P) = 0.016$, and $p(P \mid H) = 0.9999$.

**Answer a)**

Using Bayes’ rule, we will find the value of $p(H \mid P)$, which is:

$$\begin{aligned} p(H \mid P) & = \dfrac{p(P \mid H) \cdot p(H)}{p(P)} \\ & = \dfrac{0.9999 \cdot 0.008}{0.016} \\ & \approx 0.5. \end{aligned}$$So, the probability that the person chosen is truly infected with the HIV, given that they have tested positive on the diagnostic test, is approximately $\boxed{0.5}$.

**Answer b)**

Since $p(P) = 0.016$, the probability of someone getting a negative result on the diagnostic test is $p(P^c) = 1 – p(P) = 0.984$. In this case, we will find the value of $p(H \mid P^c)$, which is

$$\begin{aligned} p(H \mid P^c) & = \dfrac{p(H \cap P^c)}{p(P^c)} \\ & = \dfrac{p(H) – p(H \cap P)}{p(P^c)} \\ & = \dfrac{0.008 – (0.9999 \cdot 0.008)}{0.984} \\ & \approx 8.13 \times 10^{-7}. \end{aligned}$$So, the probability that the person chosen is actually infected with the HIV, given that they have tested negative on the diagnostic test, is approximately $\boxed{8.13 \times 10^{-7}}.$

**Problem Number 9**

In a certain country, data indicates that the probability of selecting an adult over the age of 40 with cancer is $0.05.$ If the probability of a doctor making an accurate diagnosis of someone having cancer is $0.78$, and the probability of making a misdiagnosis (diagnosing someone with cancer when they don’t have it) is $0.04$, determine:

- the probability that an adult over the age of 40 is diagnosed with cancer;
- the probability that an adult diagnosed with cancer actually has the disease.

Let $K$ and $D$ respectively denote the events of selecting an adult with cancer and the event of an adult being diagnosed with cancer, so we have the following information.

$$\begin{aligned} p(K) & = 0.05 \\ p(D \mid K) & = 0.78 \\ P(K^c) & = 1-0.05 = 0.95 \\ P(D \mid K^c) & = 0.04 \end{aligned}$$Answer a)

In this case, we will find the value of $p(D)$, which is:

$$\begin{aligned} p(D) & = p(K \cap D) + p(K^c \cap D) \\ & = p(K) \cdot p(D \mid K) + p(K^c) \cdot p(D \mid K^c) \\ & = 0.05 \cdot 0.78 + 0.95 \cdot 0.04 \\ & = 0.077. \end{aligned}$$So, the probability that an adult over the age of 40 is diagnosed with cancer is $\boxed{0.077}$.

**Answer b)**

In this case, we will find the value of $p(K \mid D)$, which is:

$$\begin{aligned} p(K \mid D) & = \dfrac{p(K \cap D)}{p(D)} \\ & = \dfrac{p(K) \cdot p(D \mid K)}{p(D)} \\ & = \dfrac{0.05 \cdot 0.78}{0.077} \\ & \approx 0.4063. \end{aligned}$$So, the probability that an adult diagnosed with cancer actually has the disease is approximately $\boxed{0.4063}$.

**Problem Number 10**

The organizing committee of an olympiad uses three hotels as accommodations for participants to stay for several days. The three hotels are Rose Hotel, Jasmine Hotel, and Orchid Hotel. Past data shows that $20\%, 50\%,$ and $30\%$ of the participants are placed in Rose Hotel, Jasmine Hotel, and Orchid Hotel, respectively. It is known that $5\%, 4\%,$ and $8\%$ respectively of the rooms in Rose Hotel, Jasmine Hotel, and Orchid Hotel experience breakdowns with the sink pipes.

- Determine the probability that a participant is placed in a room with sink pipe breakdowns.
- Determine the probability that a participant placed in a room with sink pipe breakdowns is in Hotel Orchid.

Let $W, T,$ and $A$ respectively denote the events of a participant being placed in Rose Hotel, Jasmine Hotel, and Orchid Hotel. Let $M$ be the event of a participant being placed in a room with sink pipe breakdowns. From this, we have the following information.

$$\begin{aligned} p(W) & = 20\% = 0.2 \\ p(T) & = 50\% = 0.5 \\ p(A) & = 30\% = 0.3 \\ p(M \mid W) & = 5\% = 0.05 \\ p(M \mid T) & = 4\% = 0.04 \\ p(M \mid A) & = 8\% = 0.08 \end{aligned}$$**Answer a)**

Using the theorem of total probability, we will find the value of $p(M)$, which is

$$\begin{aligned} p(M) & = p(W) \cdot p(M \mid W) + p(T) \cdot p(M \mid T) + p(A) \cdot p(M \mid A) \\ & = 0.2 \cdot 0.05 + 0.5 \cdot 0.04 + 0.3 \cdot 0.08 \\ & = 0.054. \end{aligned}$$So, the probability that a participant is placed in a room with sink pipe breakdowns is $\boxed{0.054}$.

**Answer b)**

Using Bayes’ theorem, we will find the value of $p(A \mid M)$, which is

$$\begin{aligned} p(A \mid M) & = \dfrac{p(M \mid A) \cdot p(A)}{p(M)} \\ & = \dfrac{0.08 \cdot 0.3}{0.054} \\ & = \dfrac{4}{9}. \end{aligned}$$So, the probability that a participant placed in a room with sink pipe breakdowns is in Orchid Hotel is $\boxed{\dfrac{4}{9}}$.

**Problem Number 11**

A construction company employs a number of professional welders. From previous records, the company knows that $5\%$ of the welds performed by welders do not meet industrial safety standards. In other words, these welds are defective $(D).$ Therefore, each weld on every construction project is inspected by the company’s inspector. The inspector’s performance is also monitored. Observations made over several years indicate that: (1) Every defective weld $(D)$ is classified as defective $(CD)$ by the inspector with $96\%$ accuracy, and the rest are classified as good $(CG);$ (2) Every good weld $(G)$ is classified as defective $(CD)$ $2\%$ of the time, and the rest are classified as good $(CG).$

- Draw a tree diagram representing all possible outcomes (along with their probabilities) of randomly selecting a weld for inspection and its classification by the inspector.
- If a randomly selected weld is classified as good $(GG)$ by the inspector, determine the probability that the weld is actually defective $(D).$

Let $D$ be the event of selecting a defective weld. Also, let $CD$ be the event of a weld being classified as defective, so we know $p(CD \mid D) = 96\% = 0,\!96$ and $p(CD \mid D^c) = 2\% = 0,\!02.$

**Answer a)**

The tree diagram representing the possible outcomes and their probabilities is as follows:

We obtain the following information:

$$\begin{aligned} p(D \cap CD) & = 0,\!05 \cdot 0,\!96 = 0,\!048 \\ p(D \cap CD^c) & = 0,\!05 \cdot 0,\!04 = 0,\!002 \\ p(D^c \cap CD) & = 0,\!95 \cdot 0,\!02 = 0,\!019 \\ p(D^c \cap CD^c) & = 0,\!95 \cdot 0,\!98 = 0,\!931. \end{aligned}$$**Answer** **b)**

Using Bayes’ theorem, we will find the value of \(p(D \mid CD^c)\), which is $p(D \mid CD^c),$ i.e.,

$$\begin{aligned} p(D \mid CD^c) & = \dfrac{p(D \cap CD^c)}{p(CD^c)} \\ & = \dfrac{p(D \cap CD^c)}{p(D \cap CD^c) + p(D^c \cap CD^c)} \\ & = \dfrac{0,\!002}{0,\!002 + 0,\!931} \\ & \approx 0,\!0021. \end{aligned}$$So, the probability that the weld is actually defective if classified as good $(CG)$ by the inspector is approximately $\boxed{0,\!0021}$