STAT7055 T03 Sol
STAT7055 T03 Sol
STAT7055 T03 Sol
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:
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
x
1 2 3
1 0.42 0.12 0.06
y
2 0.28 0.08 0.04
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
and
E(Y ) = 1 × 0.6 + 2 × 0.4 = 1.4
Therefore,
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
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).
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
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
(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.
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
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
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
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