ST259F23L3_Solns_Combined
pdf
keyboard_arrow_up
School
Wilfrid Laurier University *
*We aren’t endorsed by this school
Course
259
Subject
Industrial Engineering
Date
Dec 6, 2023
Type
Pages
6
Uploaded by mamba6800
ST259 Lab 3 - Fall 2023
1.
[12
marks
]
Benford°s law states that in many naturally occurring numbers that the leading signi±cant digit tends to be °small°
(e.g. stock prices, city populations). In these scenarios, the leading digit is a discrete random variable
X
with probability
mass function
p
X
(
x
) = log
k
°
1 +
1
x
±
where
k
is dependent on the number system in use (e.g. binary, decimal, etc.)
:
For the remainder of this question, suppose that
x
2 f
1
;
2
;
3
;
4
;
5
g
(i.e. the senary number system is being used).
(a) Using properties of logarithms, determine the exact value of
k:
5
X
x
=1
p
X
(
x
) = 1
)
log
k
(2) + log
k
°
3
2
±
+ log
k
°
4
3
±
+ log
k
°
5
4
±
+ log
k
°
6
5
±
= 1
)
log
k
°
2
°
3
2
°
4
3
°
5
4
°
6
5
±
= 1
)
log
k
6 = 1
)
k
= 6
(b) Rounding to 2 decimals where necessary, state:
i. The p.m.f. of
X
as a table.
x
=
1
2
3
4
5
p
X
(
x
) =
log
6
2
±
0
:
39
log
6
3
2
±
0
:
23
log
6
4
3
±
0
:
16
log
6
5
4
±
0
:
12
log
6
6
5
±
0
:
10
ii. The c.d.f. of
X
as a table.
[Note: Use interval notation for
x:
]
x
2
(
²1
;
1)
[1
;
2)
[2
;
3)
[3
;
4)
[4
;
5)
[5
;
1
)
F
X
(
x
) =
0
0
:
39
0
:
39 + 0
:
23
= 0
:
62
0
:
62 + 0
:
16
= 0
:
78
0
:
78 + 0
:
12
= 0
:
90
0
:
90 + 0
:
10
= 1
(c) To 2 decimal places, calculate (use correct notation and show your work)
P
(2
³
X
³
4)
using:
i. The p.m.f. from part (b)(i).
P
(2
³
X
³
4) =
p
X
(2) +
p
X
(3) +
p
X
(4) = 0
:
23 + 0
:
16 + 0
:
12 = 0
:
51
ii. The c.d.f. from part (b)(ii).
P
(2
³
X
³
4) =
F
X
(4)
²
F
X
(2
°
) = 0
:
90
²
0
:
39 = 0
:
51
(d) Showing your work, determine the expected value (or mean) of
X
.
Be sure to use proper notation and round result to
2 decimal places.
°
X
=
E
[
X
] =
5
X
i
=1
x
i
f
(
x
i
) = 1 (0
:
39) + 2(0
:
23) + 3 (0
:
16) + 4(0
:
12) + 5 (0
:
10) = 2
:
31
(e) Showing your work, determine the standard deviation (to 3 decimal places) in
X
.
Be sure to use proper notation and
round result to 2 decimal places.
±
X
=
p
E
[
X
2
]
²
°
2
=
v
u
u
t
5
X
i
=1
x
2
i
f
(
x
i
)
²
°
2
=
p
1 (0
:
39) + 4(0
:
23) + 9 (0
:
16) + 16(0
:
12) + 25 (0
:
10)
²
2
:
31
2
= 1
:
35
2.
[5
marks
]
Recall the Roulette question from Labs 1 and 2 where:
Event
A
:
f
ball lands in the "3rd twelve"
g
=
f
25
;
26
; :::;
35
;
36
g
with
P
(
A
) =
6
19
Event
B
:
f
ball lands on a "red" number
g
with
P
(
B
) =
9
19
Also, consider event
C
=
f
ball lands on "1st street"
g
=
f
1
;
2
;
3
g
with
P
(
C
) =
3
38
:
Suppose that you have decided to try your luck at the game and have $25 to gamble on a single spin.
Important Note
:
If a bet pays
N
to 1 odds on a wager of
$
Z
then the bettor°s winnings/pro±t is
$ (
N
´
Z
)
if they win and
²
$
Z
if they lose.
(a) Suppose you bet the entire $25 on the ball landing on a "red" number (which, if successful, pays 1 to 1 odds).
Showing
your calculation, determine your expected winnings,
E
[
W
1
]
;
to the closest cent.
E
[
W
1
] = (1
´
25)
°
9
19
±
²
25
°
1
²
9
19
±
= (1
´
25)
°
9
19
±
²
25
°
10
19
±
:
=
²
$1
:
32
(b) Suppose you bet the entire $25 on the ball landing in the "3rd twelve" (which, if successful, pays 2 to 1 odds). Showing
your calculation, determine your expected winnings,
E
[
W
2
]
;
to the closest cent.
E
[
W
2
] = (2
´
25)
°
6
19
±
²
25
°
13
19
±
:
=
²
$1
:
32
(c) Suppose you bet the entire $25 on the ball landing on "1st street" (which, if successful, pays 11 to 1 odds).
Showing
your calculation, determine your expected winnings,
E
[
W
3
]
;
to the closest cent.
E
[
W
3
] = (11
´
25)
°
3
38
±
²
25
°
35
38
±
:
=
²
$1
:
32
(d) Suppose you change up your strategy and bet $15 on event
A
, $8 on event
B
, and $2 on event
C
for one spin of the
wheel.
Showing your calculation, determine your expected winnings,
E
[
W
4
]
;
to the closest cent.
E
[
W
4
]
=
²
(1
´
8)
°
9
19
±
²
8
°
10
19
±³
+
²
(2
´
15)
°
6
19
±
²
15
°
13
19
±³
+
²
(11
´
2)
°
3
38
±
²
2
°
35
38
±³
=
²
0
:
42105
²
0
:
78947
²
0
:
10526 =
²
$1
:
32
3.
[5
marks
]
Suppose that random variable
X
represents the outcome when an
n
-sided fair die is rolled (i.e. each outcome is
equally likely to occur).
The p.m.f. of
X
is then
p
X
(
x
i
) =
1
n
where
x
i
=
i
for
1
³
i
³
n:
(a) Determine
E
[
X
]
(the expected value of
X
) in a simpli±ed form.
[Hint:
n
X
i
=1
i
=
n
(
n
+ 1)
2
]
E
[
X
] =
n
X
i
=1
x
i
p
X
(
x
i
) =
n
X
i
=1
x
i
°
1
n
±
=
1
n
n
X
i
=1
i
=
1
n
²
n
(
n
+ 1)
2
³
=
n
+ 1
2
(b) Determine
V
(
X
)
(the variance in
X
) in a simpli±ed form.
[Hint:
n
X
i
=1
i
2
=
n
(
n
+ 1)(2
n
+ 1)
6
]
E
´
X
2
µ
=
n
X
i
=1
x
2
i
°
1
n
±
=
1
n
n
X
i
=1
i
2
=
1
n
°
n
(
n
+ 1)(2
n
+ 1)
6
±
=
2
n
2
+ 3
n
+ 1
6
)
V
(
X
) =
E
´
X
2
µ
²
(
E
[
X
])
2
=
2
n
2
+ 3
n
+ 1
6
²
°
n
+ 1
2
±
2
=
2(2
n
2
+ 3
n
+ 1)
²
3(
n
2
+ 2
n
+ 1)
12
=
n
2
²
1
12
4.
[12
marks
]
In a folder that you can easily ±nd on your computer, save the ±les named:
µ
Hog.csv
(found under "Weekly Lab Information" on the lab MyLS page) which contains daily closing stock prices (in
US dollars) for Harley Davidson (HOG on the Nasdaq) in 2022 and
µ
ST259F23L3.Rmd
(found under "Lab Assignment" on the lab MyLS page)
[Note: Parts (a) to (e) in Question #4 will be completed using RStudio.
You are not required to record any of the results
on your answer sheet.
Just complete the following exercises in the ±le and then I will explain how to submit the .Rmd ±le
as a .R ±le to Gradescope at the end of the question.
For grading purposes, you must name variables the same as I have
suggested below.
Parts (f) and (g) are to be completed on your written answer sheet.]
(a) Open the
ST259F23L3.Rmd
in RStudio.
Then:
i. On the toolbar, go to
Session
I
Set Working Directory
I
Choose Directory...
and select the folder where you
saved both of the ±les.
ii. Import the Hog.csv data set into R (name it
HOG
) and then display its ±rst few rows.
(b) Calculate i) the expected value of and ii) the variance in the Hog stock prices (
P
_
USD
) using US dollars.
Call the
results
ExpP_USD
and
VarP_USD
, respectively.
(c) To convert the closing stock prices from US dollars
(
P
_
USD
)
to Canadian dollars
(
P
_
CAD
)
the formula
P
_
CAD
=
1
:
37
P
_
USD
can be used.
De±ne a new column (i.e. variable) called
P_CAD
in the
HOG
data set using the command
HOG$P_CAD=1.37*HOG$P_USD
. Then use the random variable
P
_
CAD
to calculate i) the expected value of
and ii) the variance in the Hog stock prices using Canadian dollars.
Call the results
ExpP_CAD
and
VarP_CAD
,
respectively..
[Note: To see that the variable was indeed added to the data set, type
head(HOG)
to see the data set.]
(d) Suppose that there is a $6.95 (in US dollars) brokerage fee to trade the stock.
De±ne a new column (i.e. variable) called
V_USD
in the
HOG
data set that represents the true stock values in US dollars
(
V
_
USD
=
P
_
USD
²
6
:
95)
.
Then
use the random variable
V
_
USD
to calculate i) the expected value of and ii) the variance in the true HOG stock values
using US dollars.
Call the results
ExpV_USD
and
VarV_USD
, respectively.
(e) De±ne a new column (i.e.
variable) called
V_CAD
in the
HOG
data set that represents the true stock values in
Canadian dollars
(
V
_
CAD
= 1
:
37(
P
_
USD
²
6
:
95) = 1
:
37
P
_
USD
²
9
:
5215)
.
Then use the random variable
V
_
CAD
to calculate i) the expected value of and ii) the variance in the true HOG stock values using Canadian dollars.
Call the
results
ExpV_CAD
and
VarV_CAD
, respectively.
(f) On your written answer sheet, evaluate the linear transformations in parts (c), (d), and (e) using the
E
[
P
_
USD
]
from
part (b) and compare the results to the
E
[
P
_
CAD
]
; E
[
V
_
USD
]
;
and
E
[
V
_
CAD
]
.
If
a; b
2
R
and
X
is a discrete random variable, what do these observations suggest about the relationship between
E
[
X
]
and
E
[
aX
+
b
]?
From part (c):
1
:
37
E
[
P
_
USD
] = 1
:
37(38
:
56669)
±
52
:
836 =
E
[
P
_
CAD
]
From part (d):
E
[
P
_
USD
]
²
6
:
95 = 38
:
56669
²
6
:
95
±
31
:
617 =
E
[
V
_
USD
]
From part (e):
1
:
37
E
[
P
_
USD
]
²
9
:
5215 = 1
:
37(38
:
56669)
²
9
:
5215
±
43
:
315 =
E
[
V
_
CAD
]
This all suggests that
E
[
aX
+
b
] =
aE
[
X
] +
b:
(g) On your written answer sheet, how does the
V ar
(
P
_
USD
)
compare to the
V ar
(
P
_
CAD
)
?
V ar
(
V
_
USD
)
?
V ar
(
V
_
CAD
)?
If
a; b
2
R
and
X
is a discrete random variable, what do these observations suggest about the relationship between
V ar
(
X
)
and
V ar
(
aX
+
b
)?
V ar
(
P
_
USD
) =
V ar
(
V
_
USD
)
(i.e.
b
does not a/ect variance), and
(1
:
37)
2
V ar
(
P
_
USD
) = (1
:
37)
2
(17
:
8938)
±
33
:
585 =
V ar
(
P
_
CAD
) =
V ar
(
V
_
CAD
)
:
This suggests that
V
(
aX
+
b
) =
a
2
V
(
X
)
:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Run the °nal line of code [i.e. knitr::purl("ST259F23L3.Rmd") in the °le] to convert the .RMD °le to a .R °le.
It will be saved in the same folder that you originally saved the .RMD °le. Submit the newly created
ST259F23L3.R °le to Gradescope via the website link found on the lab MyLS page.
² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ² ²
Once you have completed the problems (or your time is up), be sure that you have submitted the PDF for the R code/output in
Question #4(a)-(e) to Gradescope via the website link on the lab MyLS lab page.
Hand all other written work in to your IA/TA
(be sure your name and student ID are clearly written).
It will be uploaded separately to Gradescope for you.
Grade:
34
You should have worked through the pre-lab worksheet before attending the lab. If not, you will need to
go investigate the Lab2 Pre-Lab file under “Weekly Lab Information” for a description of the functions and
commands required below.
QUESTION #4) ON LAB ASSIGNMENT
#Part a)
HOG
=
read.csv(
"Hog.csv"
)
#HOG #Displays data set
#Part b)
ExpP_USD
=
mean(HOG$P_USD)
ExpP_USD
#Displays result
## [1] 38.56669
VarP_USD
=
sd(HOG$P_USD)ˆ
2
VarP_USD
#Displays result
## [1] 17.8938
#Part c)
HOG$P_CAD
=
1.37
*HOG$P_USD
ExpP_CAD
=
mean(HOG$P_CAD)
ExpP_CAD
## [1] 52.83637
VarP_CAD
=
sd(HOG$P_CAD)ˆ
2
VarP_CAD
## [1] 33.58488
#Part d)
HOG$V_USD
=
HOG$P_USD
-6.95
ExpV_USD
=
mean(HOG$V_USD)
ExpV_USD
## [1] 31.61669
VarV_USD
=
sd(HOG$V_USD)ˆ
2
VarV_USD
## [1] 17.8938
#Part e)
HOG$V_CAD
=
1.37
*HOG$P_USD
-9.5215
ExpV_CAD
=
mean(HOG$V_CAD)
ExpV_CAD
## [1] 43.31487
1
VarV_CAD
=
sd(HOG$V_CAD)ˆ
2
VarV_CAD
## [1] 33.58488
View(HOG)
DO NOT CHANGE THE FOLLOWING LINE OF CODE. WHEN YOU RUN IT, THE CODE WILL
CONVERT THIS .RMD FILE INTO A .R FILE FOR SUBMISSION TO GRADESCOPE. TO ENSURE
YOUR RESULTS ARE GRADED PROPERLY, MAKE SURE THE NAMES OF YOUR VARIABLES
ARE AS INDICATED ON THE ASSIGNMENT.
#knitr::purl("ST259F23L3.Rmd")
2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help