Skip to content
Gioi Toan
Start learning
A smiling die next to a coin

Notes on Lesson 19: Total probability formula and Bayes' formula (Maths 12 Ket noi tri thuc)

Lesson summary

Then we have the following formula: P(B)=P(A)⋅P(B∣A)+P(A‾)⋅P(B∣A‾)P(B) = P(A) \cdot P(B \mid A) + P(\overline{A}) \cdot P(B \mid \overline{A}).

Let AA and BB be two events, with P(B)>0P(B) > 0.

Picture event BB as the "destination", and AA and A‾\overline{A} as two roads leading to it.

This content is not yet available in English. It is shown below in the original Vietnamese.

  • Dùng công thức xác suất toàn phần và công thức Bayes; mô tả bằng sơ đồ hình cây.
  • Vận dụng vào bài toán thực tiễn.

A rapid test has high sensitivity, but when a person receives a positive result, what is the probability that they truly have the disease? The answer depends not only on sensitivity, but also on the proportion of people with the disease in the community. This lesson helps you calculate the probability of an event by splitting it into cases (the law of total probability), then "flipping it around" to find the cause once you have seen the result (Bayes' formula), and recording the whole process with a tree diagram.

Practise nowTextbook solutions for this lesson

Key ideas: what do you need to know?

The law of total probability

  • Given two events AA and BB. Then we have the following formula: P(B)=P(A)⋅P(B∣A)+P(A‾)⋅P(B∣A‾)P(B) = P(A) \cdot P(B \mid A) + P(\overline{A}) \cdot P(B \mid \overline{A}). The formula above is called the law of total probability.
  • In problems, AA is usually the "cause" (it rains, choosing to go by motorbike, having the disease), and BB is the "result" whose probability we need to calculate. For the conditional probabilities to make sense, we consider 0<P(A)<10 < P(A) < 1 (the book does not state this point in the box).
  • Meaning: event BB happens along two "paths", AA or A‾\overline{A}; the probability of BB is the sum of the probabilities of going along each path and then reaching BB.
  • Example (Example 1 of the book): on Monday Mr An takes the bus; if he takes the bus today, then tomorrow he takes the motorbike with probability 0.4, and if he takes the motorbike today, then tomorrow he takes the bus with probability 0.7. Let AA be "takes the motorbike on Tuesday" and BB be "takes the motorbike on Wednesday". We have P(A)=0,4P(A) = 0,4, P(B∣A)=1−0,7=0,3P(B \mid A) = 1 - 0,7 = 0,3, P(B∣A‾)=0,4P(B \mid \overline{A}) = 0,4, so P(B)=0,4⋅0,3+0,6⋅0,4=0,36P(B) = 0,4 \cdot 0,3 + 0,6 \cdot 0,4 = 0,36.
  • Extension, not stated in the book: if A1,A2,…,AnA_1, A_2, \ldots, A_n is a complete system of events (pairwise mutually exclusive, with union the certain event, each P(Ai)>0P(A_i) > 0) then P(B)=∑i=1nP(Ai)⋅P(B∣Ai)P(B) = \sum_{i=1}^{n} P(A_i) \cdot P(B \mid A_i). Two events AA, A‾\overline{A} are the case n=2n = 2.

In plain words: Picture event BB as the "destination", and AA and A‾\overline{A} as two roads leading to it. To find the likelihood of reaching the destination, you add two ways: going along road AA and then reaching BB, and going along road A‾\overline{A} and then reaching BB. Each way is a multiplication: the probability of choosing the road times the probability of reaching the destination once on that road. Why multiply before adding? Because the two ways are two cases that do not happen at the same time, while within each case the two steps happen one after the other. The condition 0<P(A)<10 < P(A) < 1 is needed so that both roads can be taken and the conditional probabilities P(B∣A)P(B \mid A), P(B∣A‾)P(B \mid \overline{A}) are all defined.

Phrase by phrase
complete system of events
The events are pairwise mutually exclusive and their union is the certain event, covering every possibility. The book does not state this concept.Example: AA and A‾\overline{A} form a complete system of two events.
law of total probability
Calculate P(B)P(B) as the sum of the products of the path probabilities with the conditional probabilities of reaching BB; that is the law of total probability.Example: P(B)=P(A)P(B∣A)+P(A‾)P(B∣A‾)P(B) = P(A)P(B \mid A) + P(\overline{A})P(B \mid \overline{A}).
0<P(A)<10 < P(A) < 1
The condition for both AA and A‾\overline{A} to be possible, and for the conditional probabilities to be defined.Example: If P(A)=0P(A) = 0 then P(B∣A)P(B \mid A) is not defined.
pairwise mutually exclusive
No two events in the system happen together.Example: A1,A2,A3A_1, A_2, A_3 corresponding to three different shipments do not happen together.

Bayes' formula

  • Let AA and BB be two events, with P(B)>0P(B) > 0. Then we have the following formula: P(A∣B)=P(A)⋅P(B∣A)P(A)⋅P(B∣A)+P(A‾)⋅P(B∣A‾)P(A \mid B) = \frac{P(A) \cdot P(B \mid A)}{P(A) \cdot P(B \mid A) + P(\overline{A}) \cdot P(B \mid \overline{A})}. The formula above is called Bayes' formula.
  • Note: by the law of total probability, the denominator is exactly P(B)P(B), so Bayes' formula can also be written as P(A∣B)=P(A)⋅P(B∣A)P(B)P(A \mid B) = \frac{P(A) \cdot P(B \mid A)}{P(B)}.
  • Meaning of Bayes' formula: initially event AA has probability P(A)=pP(A) = p. When we get the extra information "event BB has happened", we update our understanding of the likelihood of AA by calculating P(A∣B)P(A \mid B), the probability of AA given that BB has happened.
  • In medical testing: a false positive is a positive test when in fact the person tested does not have the disease; a false negative is a negative test when in fact the person does have the disease. You need to distinguish P(A∣B)P(A \mid B) (having the disease given a positive result) from P(B∣A)P(B \mid A) (a positive result given that the disease is present).
  • Extension, not stated in the book: with a complete system of events A1,A2,…,AnA_1, A_2, \ldots, A_n and P(B)>0P(B) > 0, P(Ak∣B)=P(Ak)⋅P(B∣Ak)∑i=1nP(Ai)⋅P(B∣Ai)P(A_k \mid B) = \frac{P(A_k) \cdot P(B \mid A_k)}{\sum_{i=1}^{n} P(A_i) \cdot P(B \mid A_i)}; the probabilities P(Ak)P(A_k) are called prior probabilities, while P(Ak∣B)P(A_k \mid B) are called posterior probabilities.

In plain words: The law of total probability goes from cause to result: knowing the proportion of each shipment and the proportion of defective items in each shipment, you can calculate the probability that a defective item is drawn. Bayes goes the other way: holding a defective item, ask which shipment it came from. The numerator is exactly the contribution of shipment AA to P(B)P(B), and the denominator is the whole of P(B)P(B). So P(A∣B)P(A \mid B) is the share of shipment AA in the total, so it always lies between 0 and 1. The condition P(B)>0P(B) > 0 is required, because P(A∣B)P(A \mid B) only makes sense when BB can happen.

Phrase by phrase
Bayes' formula
Calculate a conditional probability in the reverse direction, from the result BB inferring the cause AA; that is Bayes' formula.Example: P(A∣B)=P(A)P(B∣A)P(B)P(A \mid B) = \frac{P(A)P(B \mid A)}{P(B)}.
prior probability
The probability of AkA_k known before there is any information about BB.Example: The proportion of products from shipment 1 is P(A1)=0,4P(A_1) = 0,4.
posterior probability
The probability of AkA_k after knowing that BB has occurred.Example: P(A1∣B)P(A_1 \mid B): the probability that the product comes from batch 1, given that it is defective.
P(B)>0P(B) > 0
The condition in the book's box for P(A∣B)P(A \mid B) to make sense.Example: If P(B)=0P(B) = 0 then P(A∣B)P(A \mid B) cannot be computed.

Common mistakesComputing Bayes by dividing by the contribution of the very source being sought instead of dividing by P(B)P(B), so the result always comes out as 1.

Describe using the raw data table \(2 \times 2\) (recall Lesson 18)

Given the raw data table 2×22 \times 2 counting two criteria, each criterion split into two groups:

AAA‾\overline{A}Total
BBn11n_{11}n12n_{12}n1⋅n_{1\cdot}
B‾\overline{B}n21n_{21}n22n_{22}n2⋅n_{2\cdot}
Totaln⋅1n_{\cdot 1}n⋅2n_{\cdot 2}nn
  • Probability of the groups by column: P(A)=n⋅1nP(A) = \frac{n_{\cdot 1}}{n}, P(A‾)=n⋅2nP(\overline{A}) = \frac{n_{\cdot 2}}{n}.
  • Conditional probability is read by dividing a cell by the total of the group after the ∣| sign (a group in a column is divided by the column total, a group in a row is divided by the row total): P(B∣A)=n11n⋅1P(B \mid A) = \frac{n_{11}}{n_{\cdot 1}}, P(B∣A‾)=n12n⋅2P(B \mid \overline{A}) = \frac{n_{12}}{n_{\cdot 2}}; similarly P(A∣B)=n11n1⋅P(A \mid B) = \frac{n_{11}}{n_{1\cdot}}, P(A∣B‾)=n21n2⋅P(A \mid \overline{B}) = \frac{n_{21}}{n_{2\cdot}}.
  • Law of total probability formula: P(B)=P(A)P(B∣A)+P(A‾)P(B∣A‾)=n1⋅nP(B) = P(A)P(B \mid A) + P(\overline{A})P(B \mid \overline{A}) = \frac{n_{1\cdot}}{n}.
  • Bayes' formula: P(A∣B)=P(A)P(B∣A)P(B)=n11n1⋅P(A \mid B) = \frac{P(A)P(B \mid A)}{P(B)} = \frac{n_{11}}{n_{1\cdot}}.

In plain words: The table 2×22 \times 2 is a compact way to record all the data of the problem. Remember: to compute P(B∣A)P(B \mid A), stand at column AA and take cell B∩AB \cap A divided by the column total AA; to compute P(A∣B)P(A \mid B), stand at row BB and take cell B∩AB \cap A divided by the row total BB. The columns give the proportions of AA and A‾\overline{A}, the rows give the proportions of BB and B‾\overline{B}, and conditional probability is a cell divided by the total of the group used as the condition. This way you can check Bayes' formula and also avoid confusing P(B∣A)P(B \mid A) with P(A∣B)P(A \mid B), two completely different quantities.

Phrase by phrase
raw data table 2×22 \times 2
The raw data table 2×22 \times 2 is a table with two rows and two columns (not counting the total row and column) recording the counts of the four groups.Example: n11n_{11} is the number of elements that belong to both BB and AA.
divide by the column total
Divide by the column total: take a cell divided by the total of the column containing that cell to get the conditional probability with the group in the column as the condition.Example: P(B∣A)=n11n⋅1P(B \mid A) = \frac{n_{11}}{n_{\cdot 1}}.
divide by the row total
Divide by the row total: take a cell divided by the total of the row containing that cell to get the conditional probability with the group in the row as the condition.Example: P(A∣B)=n11n1⋅P(A \mid B) = \frac{n_{11}}{n_{1\cdot}}.
P(A∣B)=n11n1⋅P(A \mid B) = \frac{n_{11}}{n_{1\cdot}}
The posterior probability is read directly on row BB.Example: Row BB has 50 products, of which 20 belong to AA then P(A∣B)=0,4P(A \mid B) = 0,4.

TipIn the 2x2 table: the prior probability is read down the column, the column total divided by nn; the conditional probability P(B∣A)P(B\mid A) takes cell B,AB,A divided by the column total AA; the posterior P(A∣B)P(A\mid B) takes cell B,AB,A divided by the row total BB.

Describe using a tree diagram

  • Book note: one way to picture the law of total probability is a tree diagram. From the root OO, on branches OAOA and OA‾O\overline{A} write P(A)P(A) and P(A‾)P(\overline{A}); on branches ABAB and AB‾A\overline{B} write P(B∣A)P(B \mid A) and P(B‾∣A)P(\overline{B} \mid A); on branches A‾B\overline{A}B and A‾ B‾\overline{A}\,\overline{B} write P(B∣A‾)P(B \mid \overline{A}) and P(B‾∣A‾)P(\overline{B} \mid \overline{A}). There are two tree branches leading to BB, namely OABOAB and OA‾BO\overline{A}B, so P(B)=P(A)P(B∣A)+P(A‾)P(B∣A‾)P(B) = P(A)P(B \mid A) + P(\overline{A})P(B \mid \overline{A}).
  • In general (with many events, an extension): the first level from the root splits into branches A1,A2,…,AnA_1, A_2, \ldots, A_n, writing on each branch the prior probability P(Ai)P(A_i).
  • Second level: from each AiA_i split branches to BB and B‾\overline{B}, writing on the branch the conditional probability P(B∣Ai)P(B \mid A_i) and P(B‾∣Ai)P(\overline{B} \mid A_i).
  • Multiply along the path rule (the course's name): the probability of a path equals the product of the probabilities written on the branches of that path. For example, the probability of the path AiA_i then BB is P(Ai)⋅P(B∣Ai)P(A_i) \cdot P(B \mid A_i).
  • Add the branches rule (the course's name): P(B)P(B) equals the sum of the probabilities of the paths leading to BB.
  • Bayes on the tree: P(Ak∣B)P(A_k \mid B) equals the probability of the path AkA_k to BB divided by the sum of the probabilities of all paths to BB.

In plain words: The tree diagram is just the total probability and Bayes formulas drawn as a picture. Start from the root: whichever branch you turn into, multiply by that branch's probability, and when you reach the destination BB, add the paths together. To know "which branch did it come from", take that branch's path and divide by the sum of all paths to BB. Why is the multiplication rule correct? Because going along branch AiA_i and then to BB are two consecutive steps, using the conditional probability multiplication rule learned in the previous lesson. The tree is especially handy when the experiment has many levels, because each level is one branching.

Phrase by phrase
Multiply along the path rule
Multiply along the path rule: the probability of a path equals the product of the probabilities on the branches of that path.Example: The path AA then BB has probability P(A)P(B∣A)P(A)P(B \mid A).
Add the branches rule
Add the branches rule: the probability of BB equals the sum of the probabilities of the paths that all lead to BB.Example: P(B)=P(A)P(B∣A)+P(A‾)P(B∣A‾)P(B) = P(A)P(B \mid A) + P(\overline{A})P(B \mid \overline{A}).
prior probability
The number written at the first level, on a branch starting from the root.Example: Branch A1A_1 is labeled 0,40,4.
Bayes on the tree
Take the probability of one path divided by the sum of the probabilities of the paths to the same destination.Example: P(A∣B)=0,120,12+0,18=0,4P(A \mid B) = \frac{0,12}{0,12 + 0,18} = 0,4.

TipOn the tree diagram: multiply along a path, add the branches; Bayes is taking one path divided by the sum of the paths to the same destination.

Procedure for solving problems with the total probability and Bayes formulas

Four steps to follow:

  • Step 1: Name the events. Choose a complete system A1,A2,...,AnA_1, A_2, ..., A_n (usually the "origin", the "batch", the "disease status") and let event BB be the observed result.
  • Step 2: Write the prior probabilities P(Ai)P(A_i) and the conditional probabilities P(B∣Ai)P(B \mid A_i). Check ∑P(Ai)=1\sum P(A_i) = 1.
  • Step 3: Compute P(B)P(B) using the total probability formula.
  • Step 4: If the question goes backwards (given BB, ask about the origin), use Bayes' formula: take the contribution of the source you need and divide it by P(B)P(B).

After computing, check: the posterior probabilities of the whole system must add up to 1.

In plain words: These four steps are like going shopping with a list: name things first, write down the quantitative data, compute the sum, and only then answer the question. Many students go wrong just because they read the problem and rush straight into calculating, mixing up P(B∣A)P(B \mid A) and P(A∣B)P(A \mid B). The key phrase for telling them apart: an event that comes with "given that", "already drawn" is usually the condition, that is, the event after the ∣| sign; its probability sits in the denominator when using Bayes' formula. The final check is well worth doing, because if the posteriors do not add up to 1, something is certainly wrong somewhere.

Phrase by phrase
complete system
A group of cases that covers every possibility and does not overlap.Example: The three batches A1,A2,A3A_1, A_2, A_3 form a complete system.
event BB is the observed result
What you see after running the experiment.Example: The product taken out is defective.
Check ∑P(Ai)=1\sum P(A_i) = 1
Check ∑P(Ai)=1\sum P(A_i) = 1: the prior probabilities must add up to 1 because the system covers every possibility.Example: 0,4+0,35+0,25=10,4 + 0,35 + 0,25 = 1.
add up to 1
The posteriors add up to 1: after knowing BB, the product certainly comes from one of the sources.Example: P(A1∣B)+P(A2∣B)+P(A3∣B)=1P(A_1 \mid B) + P(A_2 \mid B) + P(A_3 \mid B) = 1.

TipRemember the order with the phrase "total probability goes forward, Bayes goes backward": total probability goes from the source to the result, Bayes goes from the result back to the source.

TipAfter calculating, check that the posterior probabilities of the whole system add up to exactly 1; if they do not, you made a mistake in the numerator or the denominator.

Worked examples

Example 1

A box has 3 red marbles and 7 blue marbles, and the marbles differ only in colour. Two marbles are drawn at random one after another, and the marble drawn is not put back in the box. Let BB be the event "the second marble is red". Compute P(B)P(B) using the total probability formula.

Show the solution to example 1

Step 1: Let AA be the event "the first marble is red". Then A‾\overline{A} is the event "the first marble is blue"; AA and A‾\overline{A} form a complete system of events.
Step 2: Prior probabilities: P(A)=310P(A) = \frac{3}{10}, P(A‾)=710P(\overline{A}) = \frac{7}{10}.
Step 3: Conditional probabilities: if the first marble is red, then 2 red remain among 9 marbles, so P(B∣A)=29P(B \mid A) = \frac{2}{9}; if the first marble is blue, then 3 red still remain among 9 marbles, so P(B∣A‾)=39=13P(B \mid \overline{A}) = \frac{3}{9} = \frac{1}{3}.
Why: Drawing without replacement means the denominator for the second draw is 9, while the numerator depends on the colour of the marble drawn.
Step 4: P(B)=310⋅29+710⋅39=690+2190=2790=310P(B) = \frac{3}{10} \cdot \frac{2}{9} + \frac{7}{10} \cdot \frac{3}{9} = \frac{6}{90} + \frac{21}{90} = \frac{27}{90} = \frac{3}{10}.
Result: P(B)=310P(B) = \frac{3}{10}.

Common mistakesAdding the prior probabilities without checking that the sum equals 1, or forgetting one source in the complete system so that P(B)P(B) is missing.

Example 2

A factory has two production lines. Line II produces 60% of the products, line IIII produces 40% of the products. The defective rate of line II is 2%, of line IIII is 5%. One product is taken at random. a) Compute the probability that it is defective. b) Given that the product taken is defective, compute the probability that it was produced by line II.

Show the solution to example 2

Step 1: Let A1A_1 be the event "the product is produced by line II", A2A_2 be the event "the product is produced by line IIII", BB be the event "the product is defective". A1,A2A_1, A_2 form a complete system.
Step 2: P(A1)=0,6P(A_1) = 0,6, P(A2)=0,4P(A_2) = 0,4, check 0,6+0,4=10,6 + 0,4 = 1. The conditional probabilities: P(B∣A1)=0,02P(B \mid A_1) = 0,02, P(B∣A2)=0,05P(B \mid A_2) = 0,05.
Step 3: a) P(B)=0,6⋅0,02+0,4⋅0,05=0,012+0,02=0,032P(B) = 0,6 \cdot 0,02 + 0,4 \cdot 0,05 = 0,012 + 0,02 = 0,032.
Why: The two lines are two branches that do not happen at the same time, each branch is one multiplication, then add them up.
Step 4: b) By Bayes' formula: P(A1∣B)=P(A1)P(B∣A1)P(B)=0,0120,032=0,375P(A_1 \mid B) = \frac{P(A_1)P(B \mid A_1)}{P(B)} = \frac{0,012}{0,032} = 0,375.
Step 5: Check: P(A2∣B)=0,020,032=0,625P(A_2 \mid B) = \frac{0,02}{0,032} = 0,625 and 0,375+0,625=10,375 + 0,625 = 1, they match.
Result: a) P(B)=0,032P(B) = 0,032; b) P(A1∣B)=0,375P(A_1 \mid B) = 0,375.

Example 3

A disease has a rate of 1% in the community. A test has sensitivity 95% (a person with the disease tests positive with probability 0.95) and specificity 90% (a person without the disease tests negative with probability 0.90). A person takes the test and gets a positive result. Compute the probability that the person really has the disease.

Show the solution to example 3

Step 1: Let AA be the event "the person has the disease", BB be the event "the test result is positive". AA and A‾\overline{A} form a complete system.
Step 2: P(A)=0,01P(A) = 0,01, P(A‾)=0,99P(\overline{A}) = 0,99. The sensitivity gives P(B∣A)=0,95P(B \mid A) = 0,95. The specificity 0.90 is the probability of a negative result when not having the disease, so P(B∣A‾)=1−0,90=0,10P(B \mid \overline{A}) = 1 - 0,90 = 0,10.
Why: Specificity talks about negative results, so you must take the complement to get the false positive probability.
Step 3: P(B)=0,01⋅0,95+0,99⋅0,10=0,0095+0,099=0,1085P(B) = 0,01 \cdot 0,95 + 0,99 \cdot 0,10 = 0,0095 + 0,099 = 0,1085.
Step 4: P(A∣B)=0,00950,1085≈0,0876P(A \mid B) = \frac{0,0095}{0,1085} \approx 0,0876.
Why: Positive results mostly come from the large group of people without the disease, so the probability of really having the disease is only about 8.76%, even though the sensitivity is as high as 95%.
Result: P(A∣B)≈0,0876P(A \mid B) \approx 0,0876, that is about 8.76%.

Common mistakesUsing the specificity 0.90 as P(B∣A‾)P(B \mid \overline{A}) in the test problem, while 0.90 is the probability of a negative result when not carrying the disease, one must take 1−0,90=0,101 - 0,90 = 0,10.

Common mistakesThinking that a highly sensitive test means a positive result almost certainly means having the disease, ignoring the disease rate in the community, so the posterior probability is judged completely wrong.

Example 4

(Extension: system of three events, the book only gives the formula for AA and A‾\overline{A}.) Three workshops together produce one type of product with proportions 40%, 35%, 25% respectively. The defective rates of workshop II, IIII, IIIIII are 1%, 2%, 3% respectively. Take one product at random. a) Find the probability that the product is defective. b) Given that the product is defective, find the probability that it was produced by workshop III.

Show the solution to example 4

Step 1: Let A1,A2,A3A_1, A_2, A_3 be the events "the product is produced by workshop II, IIII, IIIIII" respectively, and BB be the event "the product is defective". The three events A1,A2,A3A_1, A_2, A_3 form a complete system.
Step 2: P(A1)=0,4P(A_1) = 0,4, P(A2)=0,35P(A_2) = 0,35, P(A3)=0,25P(A_3) = 0,25, their sum equals 1. The conditional probabilities: P(B∣A1)=0,01P(B \mid A_1) = 0,01, P(B∣A2)=0,02P(B \mid A_2) = 0,02, P(B∣A3)=0,03P(B \mid A_3) = 0,03.
Step 3: a) P(B)=0,4⋅0,01+0,35⋅0,02+0,25⋅0,03=0,004+0,007+0,0075=0,0185P(B) = 0,4 \cdot 0,01 + 0,35 \cdot 0,02 + 0,25 \cdot 0,03 = 0,004 + 0,007 + 0,0075 = 0,0185.
Step 4: b) P(A3∣B)=0,25⋅0,030,0185=0,00750,0185=1537≈0,4054P(A_3 \mid B) = \frac{0,25 \cdot 0,03}{0,0185} = \frac{0,0075}{0,0185} = \frac{15}{37} \approx 0,4054.
Why: Workshop III accounts for only 25% of output but has the highest defective rate, so its contribution to defective products is greater than 25%.
Result: a) P(B)=0,0185P(B) = 0,0185; b) P(A3∣B)=1537≈0,4054P(A_3 \mid B) = \frac{15}{37} \approx 0,4054.

Common mistakesConfusing P(B∣A)P(B \mid A) with P(A∣B)P(A \mid B): the problem gives the defective rate of line II as 2%, that is P(B∣A1)=0,02P(B \mid A_1) = 0,02, but then uses 0.02 as the probability that a product comes from line II.

Example 5

A box has 5 red balls and 3 blue balls. Take one ball at random, look at its color, then put it back in the box. After that, take another ball at random. Let BB be the event "the second ball is red". a) Draw a tree diagram describing the experiment, writing the probabilities on the branches. b) Find P(B)P(B) using the rule of adding the paths. c) Given that the second ball is red, find the probability that the first ball is also red.

Show the solution to example 5

Step 1: Let AA be the event "the first ball is red". The first level of the tree has two branches: branch AA labeled 58\frac{5}{8}, branch A‾\overline{A} labeled 38\frac{3}{8}.
Step 2: Because the ball is put back in the box, the second draw still has 8 balls. From each first-level branch, two branches split off toward BB and B‾\overline{B}: on the branch toward BB write 58\frac{5}{8}, on the branch toward B‾\overline{B} write 38\frac{3}{8}, the same on both first-level branches.
Step 3: b) Multiplication rule along a path: the path AA then BB has probability 58⋅58=2564\frac{5}{8} \cdot \frac{5}{8} = \frac{25}{64}; the path A‾\overline{A} then BB has probability 38⋅58=1564\frac{3}{8} \cdot \frac{5}{8} = \frac{15}{64}. Addition rule over the paths: P(B)=2564+1564=4064=58P(B) = \frac{25}{64} + \frac{15}{64} = \frac{40}{64} = \frac{5}{8}.
Why: Because the ball is put back in the box, the two draws are independent, the probability on the second draw does not change; the result 58\frac{5}{8} matches intuition.
Step 4: c) Bayes on the tree: P(A∣B)=25/6440/64=2540=58P(A \mid B) = \frac{25/64}{40/64} = \frac{25}{40} = \frac{5}{8}.
Result: a) The tree has 4 paths, two branches at each level; b) P(B)=58P(B) = \frac{5}{8}; c) P(A∣B)=58P(A \mid B) = \frac{5}{8}.

Common mistakesIn the tree diagram, adding the probabilities on the branches instead of multiplying along one path, or multiplying the probabilities of two different paths.

Example 6

A quarantine station uses a test to detect a disease in livestock. The rate of livestock carrying the disease is 4%. For livestock carrying the disease, the test is positive with probability 0.92; for livestock not carrying the disease, the test is positive with probability 0.06. a) Make a 2x2 raw data table for 1000 animals. b) Find the probability that one animal tests positive. c) Given that one animal tests positive, find the probability that it truly carries the disease.

Show the solution to example 6

Step 1: For 1000 animals: the number carrying the disease is 1000⋅0,04=401000 \cdot 0,04 = 40, the number not carrying the disease is 960. Among the 40 animals carrying the disease, the number testing positive is 40⋅0,92=36,840 \cdot 0,92 = 36,8, round to 37; among the 960 animals not carrying the disease, the number testing positive is 960⋅0,06=57,6960 \cdot 0,06 = 57,6, round to 58.
Step 2: 2x2 table (rows are test results, columns are disease status):

Carrying the diseaseNot carrying the diseaseTotal
Positive375895
Negative3902905
Total409601000

Step 3: b) Read along the positive row: P(B)=951000=0,095P(B) = \frac{95}{1000} = 0,095.
Why: This is exactly the total probability formula 0,04⋅0,92+0,96⋅0,06=0,0368+0,0576=0,09440,04 \cdot 0,92 + 0,96 \cdot 0,06 = 0,0368 + 0,0576 = 0,0944, only slightly different because of rounding to whole numbers.
Step 4: c) Read along the positive row, the cell for carrying the disease: P(A∣B)=3795≈0,3895P(A \mid B) = \frac{37}{95} \approx 0,3895. Computed exactly with the Bayes formula: 0,03680,0944≈0,3898\frac{0,0368}{0,0944} \approx 0,3898, slightly off because of rounding the number of animals.
Why: The number of false positives (58) is greater than the number of true positives (37), so even with a positive result, the chance of truly carrying the disease is under 40%.
Result: a) The table as above; b) P(B)≈0,095P(B) \approx 0,095; c) P(A∣B)≈0,3895P(A \mid B) \approx 0,3895.

Terms

Complete system of events
The events are pairwise mutually exclusive and their union is the certain event (an extension, not stated in the book).Example: AA and A‾\overline{A} form a complete system.
The law of total probability
Calculate P(B)P(B) as the sum of the products P(Ai)P(B∣Ai)P(A_i)P(B \mid A_i).Example: P(B)=P(A)P(B∣A)+P(A‾)P(B∣A‾)P(B) = P(A)P(B \mid A) + P(\overline{A})P(B \mid \overline{A}).
Bayes' formula
Calculate the conditional probability in the reverse direction, from the result back to the cause.Example: P(A∣B)=P(A)P(B∣A)P(B)P(A \mid B) = \frac{P(A)P(B \mid A)}{P(B)}.
Prior probability
The probability of the source known before observing BB (an extension term, not used in the book).Example: P(A1)=0,4P(A_1) = 0,4.
Posterior probability
The probability of the source after knowing that BB has occurred (an extension term, not used in the book).Example: P(A1∣B)P(A_1 \mid B).
Raw data table 2×22 \times 2
A table with two rows and two columns giving the counts of four groups, used to read the probabilities.Example: P(B∣A)=n11n⋅1P(B \mid A) = \frac{n_{11}}{n_{\cdot 1}}, P(A∣B)=n11n1⋅P(A \mid B) = \frac{n_{11}}{n_{1\cdot}}.
Tree diagram
A branching figure by levels, each path from the root to a tip is one case.Example: Level 1 shows P(Ai)P(A_i), level 2 shows P(B∣Ai)P(B \mid A_i).
Multiply along the path rule
Multiplication rule along a path: the probability of a path equals the product of the probabilities on its branches (our own wording).Example: P(A)P(B∣A)P(A)P(B \mid A).
Add the branches rule
Addition rule for the branches: the probability of BB equals the sum of the probabilities of the paths that all lead to BB (our own wording).Example: P(B)P(B) is the sum of the two paths leading to BB.

Practise this lesson with instant marking and saved progress in the study app. Suggested plan: Class lessons plan, Maths 12.

Practice

Answer each question, then press Check. If you get stuck, open the hints under the question one step at a time.

Question 2 of 2Written answer · Applying

This content is not yet available in English. It is shown below in the original Vietnamese.

Một bộ lọc được sử dụng để chặn thư rác trong các tài khoản thư điện tử. Tuy nhiên, vì bộ lọc không tuyệt đối hoàn hảo nên một thư rác bị chặn với xác suất là 0,95 và một thư đúng (không phải là thư rác) bị chặn với xác suất 0,01. Thống kê cho thấy tỉ lệ thư rác là 3%.
a) Chọn ngẫu nhiên một thư bị chặn. Tính xác suất để đó là thư rác.
b) Chọn ngẫu nhiên một thư không bị chặn. Tính xác suất để đó là thư đúng.
c) Trong số các thư bị chặn, có bao nhiêu phần trăm là thư đúng? Trong số các thư không bị chặn, có bao nhiêu phần trăm là thư rác?

Do this question in your notebook and show every step. When you finish, press the button below to compare with the mark scheme.

Asking the teacher while practising is for children who have a profile. It is free to turn on: Parent sign-in.

More practice questions for you

Additional exercises

  • Dùng công thức Bayes tính xác suất của nguyên nhân (Applying)

Challenge yourself

  • Tính xác suất bằng công thức xác suất toàn phần (Applying)
  • Dùng công thức Bayes tính xác suất của nguyên nhân (Applying)

Ask a parent to sign in and create your profile to unlock more. It's free. Sign in