3-3. Conditional Probability and Independent Events

条件概率和独立事件

1. Conditional Probability

The conditional probability of A given B, denoted P(A|B)P(A|B), is the probability that event A has occurred in a trial of a random experiment for which it is known that event B has definitely occurred. It may be computed by means of the following formula:

Rule for Conditional Probability

P(AB)=P(AB)P(B)P(A|B)= \frac{P(A∩B)} {P(B)}

EXAMPLE 21. A fair die is rolled.

  1. Find the probability that the number rolled is a five, given that it is odd.

  2. Find the probability that the number rolled is odd, given that it is a five.

[ Solution ]

  1. This is the introductory example, so we already know that the answer is 1/3. To use the formula in the definition to confirm this we must replace AA in the formula (the event whose likelihood we seek to estimate) by FF and replace BB (the event we know for certain has occurred) by OO : P(FO)=P(FO)P(O)P(F|O)=\frac{P(F∩O)}{P(O)}

    Since FO={5}{1,3,5}={5},P(FO)=16.F∩O=\{5\}∩\{1,3,5\}=\{5\}, P(F∩O)=1∕6.

    Since O={1,3,5},P(O)=36.O=\{1,3,5\}, P(O)=3∕6.

    Thus P(FO)=P(FO)P(O)=1636=1/3P(F|O)=\frac{P(F∩O)}{P(O)}=\frac{1∕6}{3∕6}=1/3

  2. This is the same problem, but with the roles of FF and OO reversed. Since we are given that the number that was rolled is five, which is odd, the probability in question must be 1. To apply the formula to this case we must now replace A (the event whose likelihood we seek to estimate) by OO and BB (the event we know for certain has occurred) by FF : P(OF)=P(OF)P(F)P(O|F)=\frac{P(O∩F)}{P(F)} Obviously P(F)=16P(F)=1∕6 . In part (a) we found that P(FO)=16P(F∩O)=1∕6 . Thus P(OF)=P(OF)P(F)=1616=1P(O|F)=\frac{P(O∩F)}{P(F)}=\frac{1∕6}{1∕6}=1

  • Using Rstat Package : cprt()

library(Rstat)

# 0. Sample Space
S <- rolldie2(1); N <- nrow(S)

O <- subset(S, X1 %% 2 == 1) ; element(O); pprt(O, N)
F <- subset(S, X1 == 5); element(F); pprt(F, N)
FO <- intersect2(F, O); pprt(FO, N)

# 1. P(F|O)
pprt(FO,N) / pprt(O,N)       #  P(F∩O)/P(O)
cprt(F,O)                    #  P(F|O)

# 2. P(O|F)
pprt(FO, N) / pprt(F,N)      #  P(F∩O)/P(F)
cprt(O,F)                    #  P(O|F)

EXAMPLE 22. In a sample of 902 individuals under 40 who were or had previously been married, each person was classified according to gender and age at first marriage. The results are summarized in the following two-way classification table, where the meaning of the labels is:

  • MM : male

  • FF : female

  • EE : a teenager when first married

  • WW : in one’s twenties when first married

  • HH : in one’s thirties when first married

EE

WW

HH

Total

MM

43

293

114

450

FF

82

299

71

452

Total

125

592

185

902

The numbers in the first row mean that 43 people in the sample were men who were first married in their teens, 293 were men who were first married in their twenties, 114 men who were first married in their thirties, and a total of 450 people in the sample were men. Similarly for the numbers in the second row. The numbers in the last row mean that, irrespective of gender, 125 people in the sample were married in their teens, 592 in their twenties, 185 in their thirties, and that there were 902 people in the sample in all. Suppose that the proportions in the sample accurately reflect those in the population of all individuals in the population who are under 40 and who are or have previously been married. Suppose such a person is selected at random.

  1. Find the probability that the individual selected was a teenager at first marriage.

  2. Find the probability that the individual selected was a teenager at first marriage, given that the person is male.

[ Solution ]

It is natural to let EE also denote the event that the person selected was a teenager at first marriage and to let MM denote the event that the person selected is male.

  1. According to the table the proportion of individuals in the sample who were in their teens at their first marriage is 125/902. This is the relative frequency of such people in the population, hence P(E)=1259020.139P(E)=125∕902≈0.139 or about 14%.

  2. Since it is known that the person selected is male, all the females may be removed from consideration, so that only the row in the table corresponding to men in the sample applies:

    EE

    WW

    HH

    Total

    MM

    43

    293

    114

    450

The proportion of males in the sample who were in their teens at their first marriage is 43/450. This is the relative frequency of such people in the population of males, hence P(EM)=434500.096P(E|M)=43∕450≈0.096 or about 10%.

# 0. Data
sex <- c("M", "F")
married <- c("E", "W", "H")

x <- c(43, 293, 114, 82, 299, 71)
data <- matrix(x, ncol=3, byrow=T)
rownames(data) <- sex
colnames(data) <- married
data

# 1. E : a teenager when first married -> P(E)
E <- sum(data[,"E"]); E
S <- sum(data); S
PE <- E/S; PE

# 2. M : male, P(E|M) = P(E∩M)/P(M)
M <- sum(data["M", ]); M
ME <- data["M", "E"]; ME
ME/M

EXAMPLE 23. Suppose that in an adult population the proportion of people who are both overweight and suffer hypertension is 0.09; the proportion of people who are not overweight but suffer hypertension is 0.11; the proportion of people who are overweight but do not suffer hypertension is 0.02; and the proportion of people who are neither overweight nor suffer hypertension is 0.78. An adult is randomly selected from this population.

  1. Find the probability that the person selected suffers hypertension given that he is overweight.

  2. Find the probability that the selected person suffers hypertension given that he is not overweight.

  3. Compare the two probabilities just found to give an answer to the question as to whether overweight people tend to suffer from hypertension.

[ Solution ]

Let HH denote the event “the person selected suffers hypertension.” Let OO denote the event “the person selected is overweight.” The probability information given in the problem may be organized into the following contingency table:

OO

OcO^c

HH

0.09

0.11

HcH^c

0.02

0.78

  1. Using the formula in the definition of conditional probability, P(HO)=P(HO)P(O)=0.090.09+0.02=0.8182P(H|O)=\frac{P(H∩O)}{P(O)}=\frac{0.09}{0.09+0.02}=0.8182

  2. Using the formula in the definition of conditional probability, P(HOc)=P(HOc)P(Oc)=0.110.11+0.78=0.1236P(H|O^c)=\frac{P(H∩O^c)}{P(O^c)}=\frac{0.11}{0.11+0.78}=0.1236

  3. P(HO)=0.8182P(H|O)=0.8182 is over six times as large as P(HOc)=0.1236P(H|O^c)=0.1236 , which indicates a much higher rate of hypertension among people who are overweight than among people who are not overweight. It might be interesting to note that a direct comparison of P(HO)=0.09 P(H∩O)=0.09 and P(HOc)=0.11P(H∩O^c)=0.11 does not answer the same question.

Example 24. In Example 20, Find the probabilities of P(AB),P(AC),P(ABC),P(ABC)P(A|B), P(A|C), P(A|B∩C), P(A|B∪ C) .

[ Solution ]

library(Rstat)

# 1. P(A|B) : cprt(A,B)
cprt(A,B)

# 2. P(A|C) : cprt(A,C)
cprt(A,C)

# 3. P(A|B∩C) : cprt(A, BC)
cprt(A, BC)

# 4. P(A|B∪C) : cprt(A,BuC) 
cprt(A,BuC)

2. Independent Events

Events A and B are independent if

P(AB)=P(A)P(B)P(A∩B)=P(A)⋅P(B)

If A and B are not independent then they are dependent.

EXAMPLE 25. A single fair die is rolled. Let A={3}A=\{3\} and B={1,3,5}B=\{1,3,5\}. Are AA and BB independent?

[ Solution ]

Sample Space S={1,2,3,4,5,6}S = \{1, 2, 3, 4, 5,6\} .

In this example we can compute all three probabilities P(A)=16,P(B)=12,P(A)=1∕6, P(B)=1∕2, and P(AB)=P(3)=16.P(A∩B)=P({3})=1∕6. Since the product P(A)P(B)=(16)(12)=112P(A)⋅P(B)=(1∕6)(1∕2)=1∕12 is not the same number as P(AB)=16,P(A∩B)=1∕6, the events A and B are not independent.

EXAMPLE 26. The two-way classification of married or previously married adults under 40 according to gender and age at first marriage in "Example 21" produced the table

EE

WW

HH

Total

MM

43

293

114

450

FF

82

299

71

452

Total

125

592

185

902

Determine whether or not the events F: “female” and E: “was a teenager at first marriage” are independent.

[ Solution ]

The table shows that in the sample of 902 such adults, 452 were female, 125 were teenagers at their first marriage, and 82 were females who were teenagers at their first marriage, so that P(F)=452902P(E)=125902P(FE)=82902P(F)=\frac{452}{902} P(E)=\frac{125}{902} P(F∩E)=\frac{82}{902}

Since P(F)P(E)=452902125902=0.069P(F)⋅P(E)=\frac{452}{902}⋅\frac{125}{902}=0.069

is not the same as P(FE)=82902=0.091P(F∩E)=\frac{82}{902}=0.091

we conclude that the two events are not independent.

EXAMPLE 27. Many diagnostic tests for detecting diseases do not test for the disease directly but for a chemical or biological product of the disease, hence are not perfectly reliable. The sensitivity of a test is the probability that the test will be positive when administered to a person who has the disease. The higher the sensitivity, the greater the detection rate and the lower the false negative rate.

Suppose the sensitivity of a diagnostic procedure to test whether a person has a particular disease is 92%. A person who actually has the disease is tested for it using this procedure by two independent laboratories.

  1. What is the probability that both test results will be positive?

  2. What is the probability that at least one of the two test results will be positive?

[ Solution ]

  1. Let A1A_1 denote the event “the test by the first laboratory is positive” and let A2A_2 denote the event “the test by the second laboratory is positive.” Since A1A_1 and A2A_2 are independent, P(A1A2)=P(A1)P(A2)=0.92×0.92=0.8464P(A_1∩A_2)=P(A_1)⋅P(A_2)=0.92×0.92=0.8464

  2. Using the Additive Rule for Probability and the probability just computed, P(A1A2)=P(A1)+P(A2)P(A1A2)=0.92+0.920.8464=0.9936P(A_1∪A_2)=P(A_1)+P(A_2)−P(A_1∩A_2)=0.92+0.92−0.8464=0.9936

EXAMPLE 28. The specificity of a diagnostic test for a disease is the probability that the test will be negative when administered to a person who does not have the disease. The higher the specificity, the lower the false positive rate.

Suppose the specificity of a diagnostic procedure to test whether a person has a particular disease is 89%.

  1. A person who does not have the disease is tested for it using this procedure. What is the probability that the test result will be positive?

  2. A person who does not have the disease is tested for it by two independent laboratories using this procedure. What is the probability that both test results will be positive?

[ Solution ]

  1. Let BB denote the event “the test result is positive.” The complement of BB is that the test result is negative, and has probability the specificity of the test, 0.89. Thus P(B)=1P(Bc)=10.89=0.11.P(B)=1−P(B^c)=1−0.89=0.11.

  2. Let B1B_1 denote the event “the test by the first laboratory is positive” and let B2B_2 denote the event “the test by the second laboratory is positive.” Since B1B_1 and B2B_2 are independent, by part (a) of the example P(B1B2)=P(B1)P(B2)=0.11×0.11=0.0121.P(B_1∩B_2)=P(B_1)⋅P(B_2)=0.11×0.11=0.0121.

EXAMPLE 29. The reliability of a system can be enhanced by redundancy, which means building two or more independent devices to do the same job, such as two independent braking systems in an automobile.

Suppose a particular species of trained dogs has a 90% chance of detecting contraband in airline luggage. If the luggage is checked three times by three different dogs independently of one another, what is the probability that contraband will be detected?

[ Solution ]

Let D1D_1 denote the event that the contraband is detected by the first dog, D2D_2 the event that it is detected by the second dog, and D3D_3 the event that it is detected by the third. Since each dog has a 90% of detecting the contraband, by the Probability Rule for Complements it has a 10% chance of failing. In symbols, P(D1c)=0.10,P(D2c)=0.10,P(D^c_1)=0.10,P(D^c_2)=0.10, and P(D3c)=0.10P(D^c_3)=0.10 .

Let D denote the event that the contraband is detected. We seek P(D).P(D). It is easier to find P(Dc)P(Dc), because although there are several ways for the contraband to be detected, there is only one way for it to go undetected: all three dogs must fail. Thus Dc=D1cD2cD3c,D^c=D^c_1∩D^c_2∩D^c_3, and P(D)=1P(Dc)=1P(D1cD2cD3c)P(D)=1−P(D^c)=1−P(D^c_1∩D^c_2∩D^c_3)

But the events D1D_1, D2D_2, and D3D_3 are independent, which implies that their complements are independent, so P(D1cD2cD3c)=P(D1c)P(D2c)P(D3c)=0.10×0.10×0.10=0.001P(D^c_1∩D^c_2∩D^c_3)=P(D^c_1)⋅P(D^c_2)⋅P(D^c_3)=0.10×0.10×0.10=0.001

Using this number in the previous display we obtain P(D)=10.001=0.999.P(D)=1−0.001=0.999.

That is, although any one dog has only a 90% chance of detecting the contraband, three dogs working independently have a 99.9% chance of detecting it.

EXAMPLE 30. Five fair dice are rolled. Let A=A={Sum is even} and B=B={ It includes 1 and 6 } . Are AA and BB independent?

library(Rstat)

# 0. Sample Space
S <- rolldie2(5); N <- nrow(S)

# Define the functions
even <- function(x) (sum(x) %% 2 == 0)       # for event A
span5 <- function(x) (max(x) - min(x) == 5)  # for event B

# 1. Event A
A <- subset(S, apply(S, 1, even)); nrow(A)

# 2. Event B
B <- subset(S, apply(S, 1, span5)); nrow(B)

# 3. A and B are independent? => indep.event(A, B, N)
indep.event(A, B, N)

3. Probabilities on Tree Diagrams

EXAMPLE 31. A jar contains 10 marbles, 7 black and 3 white. Two marbles are drawn without replacement, which means that the first one is not put back before the second one is drawn.

  1. What is the probability that both marbles are black?

  2. What is the probability that exactly one marble is black?

  3. What is the probability that at least one marble is black?

[ Solution ]

library(Rstat)

x <- 0:2                    # x : number of black marbles
p_jar <- dhyper(x, 7, 3, 2) # p_jar : P(x)
p_jar

# 1. P(x=2) = p_jar[3]
p_jar[3]

# 2. P(x=1) = p_jar[2]
p_jar[2]

# 3. P(x >=1) = p_jar[2] + p_jar[3]
p_jar[2] + p_jar[3]

Probabilities on Tree Diagrams

  1. The probability of the event corresponding to any node on a tree is the product of the numbers on the unique path of branches that leads to that node from the start.

  2. If an event corresponds to several final nodes, then its probability is obtained by adding the numbers next to those nodes.

  1. 条件概率(conditional probability)

  2. 独立事件 (概率论)

Last updated