Statistics for Data Analysis Exercise 3 Solutions

Statistics for Data Analysis
Exercise 3 Solutions
1. Companies use auditors to verify the accuracy of their financial accounts. A company’s employees make erroneous entries 5% of the time.
Suppose that an auditor randomly checks three entries.
(a) Find the probability distribution for Y , the number of errors detected by the auditor.
Answer
y
0
1
2
3
P (Y = y)
0.953 = 0.857375
3 × 0.952 × 0.05 = 0.135375
3 × 0.95 × 0.052 = 0.007125
0.053 = 0.000125
(b) What is the probability that the auditor will detect more than one
error?
Answer
0.007125 + 0.000125 = 0.00725.
2. Consider the following game: the player rolls a fair die repeatedly until
he gets a 2, 3, 4, 5 or 6, then she stops.
(a) What is the probability that the player rolls the die exactly three
times?
Answer
1 1 5
5
× × =
6 6 6
216
(b) What is the expected number of rolls needed to get the first “non1”?
Answer
5
1 5
1× +2× × +3×
6
6 6
2
5
1
6
× + ··· =
6
6
5
(c) If he rolls a non-1 in the first roll, the player receives £1; if she
rolls a 1 followed by a non-1, she receives £2; if she rolls two 1s
1
followed by a non-1, she receives £4; and so on, doubling for each
1 obtained. What is the expected amount paid to the player?
Answer
5
1 5
1× +2× × +4×
6
6 6
2
1
5
5
× + ··· =
6
6
4
3. A supplier of kerosene has a 150-gallon tank that is filled at the beginning of each week. The weekly demand for his kerosene, Y , has the
following probability density function:

 y, 0 ≤ y ≤ 1
1 1 < y ≤ 1.5
f (y) =

0 otherwise
(a) Find F (y).
Answer

0
y≤0


Z ∞
 R y u du
0≤y≤1
R01
R 1.5
f (u) du =
F (y) =

u du + 1 1 du 1 ≤ y ≤ 1.5
−∞

 0
1
y ≥ 1.5

0h i
y≤0


y

2

u
 2
0≤y≤1
0
i
h
=
1
u2


+ [u]y1 1 ≤ y ≤ 1.5

2

0

1
y ≥ 1.5

0
y≤0


 y2
0≤y≤1
2
=
1

+
y
−
1
1
≤ y ≤ 1.5

 2
1
y ≥ 1.5
(b) Find P (0 ≤ Y ≤ 0.5).
Answer
F (0.5) − F (0) =
(c) Find P (0.5 ≤ Y ≤ 1.2).
Answer
2
1
8
1
1
+ 0.2 − = 0.575
2
8
4. The pH of water samples from a lake is a random variable Y , which
has probability density function given by
3
(y − 2)(6 − y) 2 ≤ y ≤ 6
32
f (y) =
0
otherwise.
F (1.2) − F (0.5) =
Find E(Y ) and V ar(Y ).
Answer
Z
∞
E(Y ) =
yf (y) dy
−∞
Z 6
3
y (y − 2)(6 − y) dy
32
Z2 6 3 3 3 2 9
=
− y + y − y dy
32
4
8
2
6
3 4 1 3
9 2
= −
y + y − y
128
4
16
2
81 3
9
243
+ 54 −
+ −2+
= −
8
4
8
4
= 4
Z ∞
2
y 2 f (y) dy
E(Y ) =
−∞
Z 6
3
=
y 2 (y − 2)(6 − y) dy
32
Z2 6 3 4 3 3 9 2
=
− y + y − y
dy
32
4
8
2
6
3 5
3 4 3 3
= −
y + y − y
160
16
8
2
729
3
= −
+ 243 − 81 + − 3 + 3
5
5
84
=
5
84
⇒ V ar(Y ) =
− 42
5
4
=
5
=
3
5. R practical exercise
In Exercise 1 you created a data frame with inflation and unemployment
rates for several countries. Some economists use the so-called “misery
index”, one version of which is the inflation rate plus 1.7 times the
unemployment rate. Calculate this for each country, add it to the data
frame and calculate the same statistics for the misery index as you did
for the other variables.
Answer
Add the following commands to those given in Exercise 1:
attach(EconDat)
Misery <- X+1.7*Y
EconDat <- cbind(EconDat,Misery)
max(Misery)
min(Misery)
max(Misery)-min(Misery)
median(Misery)
IQR(Misery)
mean(Misery)
var(Misery)
sd(Misery)
boxplot(Misery)
hist(Misery)
plot(ecdf(Misery))
4