STAT7055 T03 Sol

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

STAT7055 Topic 03 Tutorial Solutions

1. Suppose the random variable X has the following probability distribution:

x 0 1 2
p(x) 0.6 0.3 0.1

Calculate the following (do it manually first, then try doing it in R using the sum func-
tion):
(a) E(X)
Solution:
󰁛
E(X) = (x × p(x)) = 0 × 0.6 + 1 × 0.3 + 2 × 0.1 = 0.5
all x

To do this in R, we would first create vectors for the x values and their corresponding
probabilities:
> x <- 0:2
> px <- c(0.6,0.3,0.1)
Noting the multiplying vectors in R is done elementwise, we can use the sum function
to work out E(X):
> E.X <- sum(x*px)
> E.X
[1] 0.5
(b) V (X)
Solution:

V (X) = E(X 2 ) − (E(X))2


󰀣 󰀤
󰁛󰀃 󰀄
= x2 × p(x) − 0.52
󰀃 all x 󰀄
= 02 × 0.6 + 12 × 0.3 + 22 × 0.1 − 0.52
= 0.45

In R, we can first calculate E(X 2 ) and use the value of E(X) calculate previously
to then use this to calculate V (X):
> E.X.sq <- sum(x^2*px)
> V.X <- E.X.sq-E.X^2
> V.X
[1] 0.45
󰀓√ 󰀔
(c) E X

Page 1 of 9
STAT7055 Topic 03 Tutorial Solutions

Solution:
󰀓√ 󰀔 󰁛 󰀃√ 󰀄 √ √ √
E X = x × p(x) = 0 × 0.6 + 1 × 0.3 + 2 × 0.1 = 0.4414
all x

In R, we can use the sqrt function to find the square-root of all the x values:
> E.sqrt.X <- sum(sqrt(x)*px)
> E.sqrt.X
[1] 0.4414214
󰀓√ 󰀔
(d) V X
Solution:
󰀓√ 󰀔 󰀕󰀓 󰀖 󰀓 󰀓
√ 󰀔2 √ 󰀔󰀔2
V X =E X − E X = E(X)−0.44142 = 0.5−0.44142 = 0.3051


In R, using the values of E(X) and E( X) calculated previously, we get:
> V.sqrt.X <- E.X - E.sqrt.X^2
> V.sqrt.X
[1] 0.3051472

2. The joint probability distribution of X and Y is shown in the following table:

x
1 2 3
1 0.42 0.12 0.06
y
2 0.28 0.08 0.04

(a) Calculate P ({X > 1}|{Y < 2}).


Solution: Using the definition of conditional probability:

P ({X > 1} ∩ {Y < 2}) 0.12 + 0.06


P ({X > 1}|{Y < 2}) = = = 0.3
P (Y < 2) 0.42 + 0.12 + 0.06
(b) Calculate the correlation coefficient between X and Y .
Solution: The marginal distribution of X and Y is given by the column and row
sums of the table of the joint probability distribution:

x
1 2 3 pY (y)
1 0.42 0.12 0.06 0.6
y
2 0.28 0.08 0.04 0.4
pX (x) 0.7 0.2 0.1 1

Page 2 of 9
STAT7055 Topic 03 Tutorial Solutions

We will now use the shortcut formula to calculate the covariance of X and Y . From
the marginal distributions, we know that

E(X) = 1 × 0.7 + 2 × 0.2 + 3 × 0.1 = 1.4

and
E(Y ) = 1 × 0.6 + 2 × 0.4 = 1.4
Therefore,

Cov(X, Y ) = E(XY ) − E(X)E(Y )


󰀣 󰀤
󰁛󰁛
= (xy × p(x, y)) − E(X)E(Y )
all x all y

= (1 × 1 × 0.42 + 1 × 2 × 0.28 + 2 × 1 × 0.12 + 2 × 2 × 0.08


+ 3 × 1 × 0.06 + 3 × 2 × 0.04) − 1.4 × 1.4
=0

Since the covariance is equal to 0, we know that the correlation coefficient is also
equal to 0:
Cov(X, Y ) 0
ρXY = = =0
σX σY σX σY
(c) Are X and Y independent?
Solution: We have just shown that X and Y are uncorrelated, but that does not
necessarily imply that X and Y are independent. Recall that independence implies
a correlation of 0, but a correlation of 0 does not imply independence. To show
independence of two discrete random variables, we need to go back to the definition.
Looking at both the joint probability distribution and the two marginal distributions,
X and Y are indeed independent, since for every possible pair of x and y values,
we have:
p(x, y) = pX (x) × pY (y)
X Y
(d) Determine the probability distribution of Y
+ X
.
Solution: Let Z = X Y
+X Y
. The possible values Z can take are 2, 52 , 10
3
and 13
6
.
We can see this from the following table of z values:

x
1 2 3
1 1 2 1 5 3 1 10
1 z= 1
+ 1
=2 z= 1
+ 2
= 2
z= 1
+ 3
= 3
y 1 2 5 2 2 3 2 13
2 z= 2
+ 1
= 2
z= 2
+ 2
=2 z= 2
+ 3
= 6

Page 3 of 9
STAT7055 Topic 03 Tutorial Solutions

Hence we get our probability distribution:

P (Z = 2) = p(1, 1) + p(2, 2) = 0.42 + 0.08 = 0.5


󰀕 󰀖
5
P Z= = p(2, 1) + p(1, 2) = 0.28 + 0.12 = 0.4
2
󰀕 󰀖
10
P Z= = p(3, 1) = 0.06
3
󰀕 󰀖
13
P Z= = p(3, 2) = 0.04
6

We should double check to make sure the probabilities add up to 1 and indeed they
do.

3. A new surgical procedure is said to be successful 80% of the time. Suppose that the
operation is performed five times, with the results being independent of each other. We
are interested in the successfulness of this operation.
(a) Define an appropriate random variable X for this problem.
Solution: An appropriate random variable would be to let X be the number of
successful operations in five trials.
(b) What particular type of distribution does the random variable X have? State the
values of the parameters.
Solution: X has a Binomial distribution, with n = 5 trials and success probability
p = 0.8. That is, X ∼ Bin(n = 5, p = 0.8).

Find the following probabilities:


(c) Exactly three operations are successful.
Solution: P (X = 3) = P (X ≤ 3) − P (X ≤ 2) = 0.2627 − 0.0579 = 0.2048
(d) Fewer than two operations are successful.
Solution: P (X < 2) = P (X ≤ 1) = 0.0067
(e) More than three are successful.
Solution: P (X > 3) = 1 − P (X ≤ 3) = 1 − 0.2627 = 0.7373

Page 4 of 9
STAT7055 Topic 03 Tutorial Solutions

4. A home security system is designed to have a 98% reliability rate. That is, in the event of
a true burglary attempt, there is a 98% chance that the alarm will be triggered. Suppose
that nine homes equipped with the system experience attempted burglaries. Find the
probability that:
(a) At least one alarm is triggered.
Solution: Let X be the number of alarms that are triggered. Then X ∼ Bin(n =
9, p = 0.98). We want to find P (X ≥ 1):

P (X ≥ 1) = 1 − P (X = 0)
9!
=1− × 0.980 × (1 − 0.98)9
0!(9 − 0)!
= 1 − 0.029
≈1
(b) More than seven of the alarms are triggered.
Solution: We want to find P (X > 7):

P (X > 7) = P (X = 8) + P (X = 9)
9! 9!
= × 0.988 × (1 − 0.98)1 + × 0.989 × (1 − 0.98)0
8!(9 − 8)! 9!(9 − 9)!
= 9 × 0.988 × 0.02 + 0.989
= 0.9869

5. It is recommended that women over 40 have a mammogram annually. A recent report


indicated that if a woman has annual mammograms over a 10-year period, there is a
60% probability that there will be at least one false-positive result. If the annual test
results are independent, what is the probability that in any one year a mammogram will
produce a false-positive result?

Solution: Let X be the number of false-positive results produced over a 10-year period.
Since tests are taken once a year and the test results are independent, X has a Binomial
distribution with parameters n = 10 trials and p equal to the probability that a mam-
mogram will produce a false-positive result in any one year. Rather than asking us to
find the probability of some event, this question is asking us to find out what p actually
is. What other information is given to us? We also know that there is a 60% proba-
bility that there will be at least one false-positive result over a 10-year period. That is,
P (X ≥ 1) = 0.6. But we also know that:

P (X = 0) = 1 − P (X ≥ 1) = 1 − 0.6 = 0.4

and
10!
P (X = 0) = p0 (1 − p)10 = (1 − p)10
0!(10 − 0)!

Page 5 of 9
STAT7055 Topic 03 Tutorial Solutions

Combining the above two equations, we get:

(1 − p)10 = 0.4

10
1 − p = 0.4

10
p = 1 − 0.4
∴ p = 0.0876

So the probability that a mammogram will produce a false-positive result in any one year
is 0.0876.

6. A student takes an examination consisting of two multiple choice questions. Each mul-
tiple choice question has four possible answers with only one correct. For the first
question, suppose the probability that he knows the answer is 0.8 and the probability
that he guesses is 0.2. If he guesses, he randomly chooses one of the four possible an-
swers. For the second question, suppose the student gains confidence if he knew the
answer to the first question. Specifically, if he knew the answer to the first question,
then for the second question the probability that he knows the answer becomes 0.9 and
the probability that he guesses becomes 0.1. If he does not know the answer to the
first question, then for the second question the probability that he knows the answer
and the probability that he guesses remain 0.8 and 0.2, respectively. Letting X denote
the number of questions he gets correct, calculate the probability distribution of X and
calculate the expected value of X.

Solution: Let’s define some events:

K1 = the student knows the answer to Q1;


K1C = the student doesn’t know the answer to Q1;
R1 = the student answers Q1 correctly;
R1C = the student answers Q1 incorrectly;
K2 = the student knows the answer to Q2;
K2C = the student doesn’t know the answer to Q2;
R2 = the student answers Q2 correctly;
R2C = the student answers Q2 incorrectly;

Consider the following event (or outcome):

K1 ∩ R 1 ∩ K2 ∩ R 2

This is the event that the student knows the answer to Q1 and answers it correctly,
and knows the answer to Q2 and answers it correctly. Since this event involves R1 and
R2 , the student answered both questions correctly and so X = 2. We can calculate the

Page 6 of 9
STAT7055 Topic 03 Tutorial Solutions

probability of this event by repeated applications of the Multiplication Rule:


P (K1 ∩ R1 ∩ K2 ∩ R2 ) = P (R2 |{K1 ∩ R1 ∩ K2 }) × P (K1 ∩ R1 ∩ K2 )
= P (R2 |{K1 ∩ R1 ∩ K2 }) × P (K2 |{K1 ∩ R1 }) × P (K1 ∩ R1 )
= P (R2 |{K1 ∩ R1 ∩ K2 }) × P (K2 |{K1 ∩ R1 }) × P (R1 |K1 )
× P (K1 )
Now if the student knew the answer to Q2, then they must answer Q2 correctly. Hence
P (R2 |{K1 ∩R1 ∩K2 }) = 1. Given that the student knew the answer to Q1, the probability
that they knew the answer to Q2 is 0.9. Hence P (K2 |{K1 ∩ R1 }) = 0.9. Again if the
student knew the answer to Q1, then they must answer Q1 correctly, so P (R1 |K1 ) = 1.
Finally we know that P (K1 ) = 0.8. Putting all this together we get:
P (K1 ∩ R1 ∩ K2 ∩ R2 ) = 1 × 0.9 × 1 × 0.8 = 0.72

Now consider the event (or outcome):


K1C ∩ R1C ∩ K2C ∩ R2C
This is the event that the student doesn’t know the answer to Q1 and answers it incor-
rectly, and doesn’t know the answer to Q2 and answers it incorrectly. Since this event
involves R1C and R2C , the student got both questions wrong and so X = 0. We can
calculate the probability as:
P (K1C ∩ R1C ∩ K2C ∩ R2C )
= P (R2C |{K1C ∩ R1C ∩ K2C }) × P (K2C |{K1C ∩ R1C }) × P (R1C |K1C ) × P (K1C )
Now if the student doesn’t know the answer to Q2, then they guess and the probability
that they answer Q2 incorrectly is 0.75, so P (R2C |{K1C ∩ R1C ∩ K2C }) = 0.75. Given
that the student didn’t know the answer to Q1, the probability that they don’t know the
answer to Q2 is 0.2. Hence P (K2C |{K1C ∩ R1C }) = 0.2. Again P (R1C |K1C ) = 0.75 and
P (K1C ) = 0.2. Putting all this together we get:
P (K1C ∩ R1C ∩ K2C ∩ R2C ) = 0.75 × 0.2 × 0.75 × 0.2 = 0.0225
Proceeding in a similar manner for all possible outcomes of the exam, we get the following
results:

Outcome x p(x)
K1C ∩ R1C ∩ K2C ∩ R2C 0 0.2 × 0.75 × 0.2 × 0.75 = 0.0225
K1C ∩ R1C ∩ K2C ∩ R2 1 0.2 × 0.75 × 0.2 × 0.25 = 0.0075
K1C ∩ R1C ∩ K2 ∩ R2 1 0.2 × 0.75 × 0.8 × 1 = 0.12
K1C ∩ R1 ∩ K2C ∩ R2C 1 0.2 × 0.25 × 0.2 × 0.75 = 0.0075
K1C ∩ R1 ∩ K2C ∩ R2 2 0.2 × 0.25 × 0.2 × 0.25 = 0.0025
K1C ∩ R1 ∩ K2 ∩ R2 2 0.2 × 0.25 × 0.8 × 1 = 0.04
K1 ∩ R1 ∩ K2C ∩ R2C 1 0.8 × 1 × 0.1 × 0.75 = 0.06
K1 ∩ R1 ∩ K2C ∩ R2 2 0.8 × 1 × 0.1 × 0.25 = 0.02
K1 ∩ R 1 ∩ K2 ∩ R 2 2 0.8 × 1 × 0.9 × 1 = 0.72

Page 7 of 9
STAT7055 Topic 03 Tutorial Solutions

Notice that any outcome involving K1 ∩ R1C or K2 ∩ R2C are not listed as they have 0
probability of occurring.
Alternatively, we can construct a tree diagram that lists the relevant conditional proba-
bilities:

1 R2 |{K1 ∩ R1 ∩ K2 } 0.72, x = 2
K2 |{K1 ∩ R1 }
0.9 0 R2C |{K1 ∩ R1 ∩ K2 }
R1 |K1
0.1 0.25 R2 |{K1 ∩ R1 ∩ K2C } 0.02, x = 2
1 K2C |{K1 ∩ R1 }
0.75 R2C |{K1 ∩ R1 ∩ K2C } 0.06, x = 1
K1

0
0.8

R1C |K1

1 R2 |{K1C ∩ R1 ∩ K2 } 0.04, x = 2
K2 |{K1C ∩ R1 }
0.8 0 R2C |{K1C ∩ R1 ∩ K2 }
R1 |K1C
0. 2

0.2 0.25 R2 |{K1C ∩ R1 ∩ K2C } 0.0025, x = 2


25
0. K2C |{K1C ∩ R1 }
0.75 R2C |{K1C ∩ R1 ∩ K2C } 0.0075, x = 1
K1C
1 R2 |{K1C ∩ R1C ∩ K2 } 0.12, x = 1
0. K2 |{K1C ∩ R1C }
75
0.8 0 R2C |{K1C ∩ R1C ∩ K2 }
R1C |K1C
0.2 0.25 R2 |{K1C ∩ R1C ∩ K2C } 0.0075, x = 1
K2C |{K1C ∩ R1C }
0.75 R2C |{K1C ∩ R1C ∩ K2C } 0.0225, x = 0

By adding together the probabilities for common values of x we get the probability distri-
bution of X:

x 0 1 2
p(x) 0.0225 0.195 0.7825

Therefore the expected value of X is:


2
󰁛
E(X) = (x × p(x)) = 0 × 0.0225 + 1 × 0.195 + 2 × 0.7825 = 1.76
x=0

Page 8 of 9
STAT7055 Topic 03 Tutorial Solutions

7. Discussion Question
Find an example of two independent discrete random variables for which their sum and
difference have the same spread. That is, V (X + Y ) = V (X − Y ) = V (X) + V (Y ).

8. swirl
Work through lessons 5 (note that we will cover the normal distribution in Topic 4) and
6 of the R Programming course.

Page 9 of 9

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy