Notes on Lesson 19: Total probability formula and Bayes' formula (Maths 12 Ket noi tri thuc)
Lesson summary
Then we have the following formula: .
Let and be two events, with .
Picture event as the "destination", and and 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.
Key ideas: what do you need to know?
The law of total probability
- Given two events and . Then we have the following formula: . The formula above is called the law of total probability.
- In problems, is usually the "cause" (it rains, choosing to go by motorbike, having the disease), and is the "result" whose probability we need to calculate. For the conditional probabilities to make sense, we consider (the book does not state this point in the box).
- Meaning: event happens along two "paths", or ; the probability of is the sum of the probabilities of going along each path and then reaching .
- 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 be "takes the motorbike on Tuesday" and be "takes the motorbike on Wednesday". We have , , , so .
- Extension, not stated in the book: if is a complete system of events (pairwise mutually exclusive, with union the certain event, each ) then . Two events , are the case .
In plain words: Picture event as the "destination", and and as two roads leading to it. To find the likelihood of reaching the destination, you add two ways: going along road and then reaching , and going along road and then reaching . 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 is needed so that both roads can be taken and the conditional probabilities , 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: and form a complete system of two events.
- law of total probability
- Calculate as the sum of the products of the path probabilities with the conditional probabilities of reaching ; that is the law of total probability.Example: .
- The condition for both and to be possible, and for the conditional probabilities to be defined.Example: If then is not defined.
- pairwise mutually exclusive
- No two events in the system happen together.Example: corresponding to three different shipments do not happen together.
Bayes' formula
- Let and be two events, with . Then we have the following formula: . The formula above is called Bayes' formula.
- Note: by the law of total probability, the denominator is exactly , so Bayes' formula can also be written as .
- Meaning of Bayes' formula: initially event has probability . When we get the extra information "event has happened", we update our understanding of the likelihood of by calculating , the probability of given that 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 (having the disease given a positive result) from (a positive result given that the disease is present).
- Extension, not stated in the book: with a complete system of events and , ; the probabilities are called prior probabilities, while 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 to , and the denominator is the whole of . So is the share of shipment in the total, so it always lies between 0 and 1. The condition is required, because only makes sense when can happen.
Phrase by phrase
- Bayes' formula
- Calculate a conditional probability in the reverse direction, from the result inferring the cause ; that is Bayes' formula.Example: .
- prior probability
- The probability of known before there is any information about .Example: The proportion of products from shipment 1 is .
- posterior probability
- The probability of after knowing that has occurred.Example: : the probability that the product comes from batch 1, given that it is defective.
- The condition in the book's box for to make sense.Example: If then cannot be computed.
Common mistakesComputing Bayes by dividing by the contribution of the very source being sought instead of dividing by , 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 counting two criteria, each criterion split into two groups:
| Total | |||
|---|---|---|---|
| Total |
- Probability of the groups by column: , .
- 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): , ; similarly , .
- Law of total probability formula: .
- Bayes' formula: .
In plain words: The table is a compact way to record all the data of the problem. Remember: to compute , stand at column and take cell divided by the column total ; to compute , stand at row and take cell divided by the row total . The columns give the proportions of and , the rows give the proportions of and , 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 with , two completely different quantities.
Phrase by phrase
- raw data table
- The raw data table is a table with two rows and two columns (not counting the total row and column) recording the counts of the four groups.Example: is the number of elements that belong to both and .
- 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: .
- 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: .
- The posterior probability is read directly on row .Example: Row has 50 products, of which 20 belong to then .
TipIn the 2x2 table: the prior probability is read down the column, the column total divided by ; the conditional probability takes cell divided by the column total ; the posterior takes cell divided by the row total .
Describe using a tree diagram
- Book note: one way to picture the law of total probability is a tree diagram. From the root , on branches and write and ; on branches and write and ; on branches and write and . There are two tree branches leading to , namely and , so .
- In general (with many events, an extension): the first level from the root splits into branches , writing on each branch the prior probability .
- Second level: from each split branches to and , writing on the branch the conditional probability and .
- 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 then is .
- Add the branches rule (the course's name): equals the sum of the probabilities of the paths leading to .
- Bayes on the tree: equals the probability of the path to divided by the sum of the probabilities of all paths to .
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 , 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 . Why is the multiplication rule correct? Because going along branch and then to 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 then has probability .
- Add the branches rule
- Add the branches rule: the probability of equals the sum of the probabilities of the paths that all lead to .Example: .
- prior probability
- The number written at the first level, on a branch starting from the root.Example: Branch is labeled .
- 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: .
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 (usually the "origin", the "batch", the "disease status") and let event be the observed result.
- Step 2: Write the prior probabilities and the conditional probabilities . Check .
- Step 3: Compute using the total probability formula.
- Step 4: If the question goes backwards (given , ask about the origin), use Bayes' formula: take the contribution of the source you need and divide it by .
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 and . 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 form a complete system.
- event is the observed result
- What you see after running the experiment.Example: The product taken out is defective.
- Check
- Check : the prior probabilities must add up to 1 because the system covers every possibility.Example: .
- add up to 1
- The posteriors add up to 1: after knowing , the product certainly comes from one of the sources.Example: .
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 be the event "the second marble is red". Compute using the total probability formula.
Show the solution to example 1
Step 1: Let be the event "the first marble is red". Then is the event "the first marble is blue"; and form a complete system of events.
Step 2: Prior probabilities: , .
Step 3: Conditional probabilities: if the first marble is red, then 2 red remain among 9 marbles, so ; if the first marble is blue, then 3 red still remain among 9 marbles, so .
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: .
Result: .
Common mistakesAdding the prior probabilities without checking that the sum equals 1, or forgetting one source in the complete system so that is missing.
Example 2
A factory has two production lines. Line produces 60% of the products, line produces 40% of the products. The defective rate of line is 2%, of line 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 .
Show the solution to example 2
Step 1: Let be the event "the product is produced by line ", be the event "the product is produced by line ", be the event "the product is defective". form a complete system.
Step 2: , , check . The conditional probabilities: , .
Step 3: a) .
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: .
Step 5: Check: and , they match.
Result: a) ; b) .
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 be the event "the person has the disease", be the event "the test result is positive". and form a complete system.
Step 2: , . The sensitivity gives . The specificity 0.90 is the probability of a negative result when not having the disease, so .
Why: Specificity talks about negative results, so you must take the complement to get the false positive probability.
Step 3: .
Step 4: .
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: , that is about 8.76%.
Common mistakesUsing the specificity 0.90 as in the test problem, while 0.90 is the probability of a negative result when not carrying the disease, one must take .
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 and .) Three workshops together produce one type of product with proportions 40%, 35%, 25% respectively. The defective rates of workshop , , 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 be the events "the product is produced by workshop , , " respectively, and be the event "the product is defective". The three events form a complete system.
Step 2: , , , their sum equals 1. The conditional probabilities: , , .
Step 3: a) .
Step 4: b) .
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) ; b) .
Common mistakesConfusing with : the problem gives the defective rate of line as 2%, that is , but then uses 0.02 as the probability that a product comes from line .
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 be the event "the second ball is red". a) Draw a tree diagram describing the experiment, writing the probabilities on the branches. b) Find 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 be the event "the first ball is red". The first level of the tree has two branches: branch labeled , branch labeled .
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 and : on the branch toward write , on the branch toward write , the same on both first-level branches.
Step 3: b) Multiplication rule along a path: the path then has probability ; the path then has probability . Addition rule over the paths: .
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 matches intuition.
Step 4: c) Bayes on the tree: .
Result: a) The tree has 4 paths, two branches at each level; b) ; c) .
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 , the number not carrying the disease is 960. Among the 40 animals carrying the disease, the number testing positive is , round to 37; among the 960 animals not carrying the disease, the number testing positive is , round to 58.
Step 2: 2x2 table (rows are test results, columns are disease status):
| Carrying the disease | Not carrying the disease | Total | |
|---|---|---|---|
| Positive | 37 | 58 | 95 |
| Negative | 3 | 902 | 905 |
| Total | 40 | 960 | 1000 |
Step 3: b) Read along the positive row: .
Why: This is exactly the total probability formula , only slightly different because of rounding to whole numbers.
Step 4: c) Read along the positive row, the cell for carrying the disease: . Computed exactly with the Bayes formula: , 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) ; c) .
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: and form a complete system.
- The law of total probability
- Calculate as the sum of the products .Example: .
- Bayes' formula
- Calculate the conditional probability in the reverse direction, from the result back to the cause.Example: .
- Prior probability
- The probability of the source known before observing (an extension term, not used in the book).Example: .
- Posterior probability
- The probability of the source after knowing that has occurred (an extension term, not used in the book).Example: .
- Raw data table
- A table with two rows and two columns giving the counts of four groups, used to read the probabilities.Example: , .
- Tree diagram
- A branching figure by levels, each path from the root to a tip is one case.Example: Level 1 shows , level 2 shows .
- 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: .
- Add the branches rule
- Addition rule for the branches: the probability of equals the sum of the probabilities of the paths that all lead to (our own wording).Example: is the sum of the two paths leading to .
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.
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