Math277 Assignment1 2024 Solutions
Math277 Assignment1 2024 Solutions
Question 1 [5 marks]
A fair die is thrown until a 6 appears. What is the probability that it must be cast more than five times?
Solution:
Lets start determining the random variable X which is number of attempt.
Our second step is determining the success probability p = 1/6.
The third step is identifying that this distribution is a geometric distribution. So, we want to find P (X > 5),
which is equal to P (X > 5) = 1 − P (X ≤ 5).
We can identify this a geometric distribution, therefore we know
P (X = x) = (1 − p)x−1 p
Method 1.
We can apply a summation of all the values of x of interest.
P (X > 5) = 1 − P (X ≤ 5)
5
X
=1− (1 − p)x−1 p
i=1
5
X 1 1
=1− (1 − )x−1
i=1
6 6
5
1X
=1− (5/6)x−1
6 i=1
= 0.402
Method 2:
Think carefully about this situation would make you realize all we need to know is the probability of
P (X > x) = 1 − (1 − p)x+1
= 1 − (1 − (5/6)5 )
= (5/6)5
= 0.402
Method 3:
We can solve this with
p= 1/6
q = 5/6
x <- seq(1,5)
f = p*qˆ(x-1)
prob <-1-sum(f)
cdf <- pgeom(x-1,1/6)
prob2 <- 1-cdf[5]
prob
1
## [1] 0.4018776
prob2
## [1] 0.4018776
Question 2 [5 marks]
Supposed 5% of men and 0.25% of women are color-blind. A person is chosen at random, and that person is
color-blind. What is the probability this person is male? (Assume a population with only males and females
with equal numbers)
Solution:
We starting by stating events: M , F and CB=color-blind and CB= is not color-blind.
We can identify two probabilities: P (M ) = 0.5 and P (F ) = 0.5. This are complementary P (F ) + P (M ) = 1.
We know two conditional probabilities P (CB|M ) = 0.05, P (CB|W ) = 0.0025.
Question 3 [5 marks]
Suppose heights of male (cm) is normally distributed as
N (µ = 180, σ 2 = 6.02 )
where the mean µ = 180 and the standard deviation σ = 6.0. Do the followings with R: 1. What proportion
of males is taller than 185cm?
1-pnorm(q=185,mean=180, sd=6.0)
## [1] 0.2023284
20.2% of the males are taller than 185 cm.
2. What proportion of heights of male is in the interval
## [1] 0.9500042
95% of heights of male is in the interval (180 − 1.96 ∗ 6.0, 180 + 1.96 ∗ 6.0)
3. Create a plot of probability density function (pdf) of the normal distribution.
# Make pdf plot
x <- seq(180-3*6.0, 180+3*6.0 ,0.01)
p <- dnorm(x, mean=180, sd=6.0)
plot(x,p,type="l", main="pdf of Height of male distribution")
2
pdf of Height of male distribution
0.06
0.04
p
0.02
0.00
x 4. Cre-
ate a plot of cdf of the normal distribution.
# Make cdf plot
q <- seq(180-3*6.0, 180+3*6.0 ,0.01)
p <- pnorm(q, mean=180, sd=6.0)
plot(q,p,type="l", main="cdf of Heights of male distribution")
0.4
0.2
0.0
q 5.
3
Draw a random sample of size 1000 from the distribution. Plot a histogram and calculate the sample mean
and the sample variance. The sample mean and the sample variance are estimators of what values?
# take random sample of size 1000 from N(mean=180, sd=6.0)
sim <- rnorm(n=1000,mean=180, sd=6.0)
hist(sim)
Histogram of sim
300
200
Frequency
50 100
0
sim
mean(sim)
## [1] 179.9398
var(sim)
## [1] 35.46604
Question 4 [10 marks]
Given the pdf of fX (x) = 42x5 (1 − x) for 0 < x < 1 and transformation Y = X 3 .
a.) Find the pdf of Y . b.) Show that the pdf of Y integrates to 1.
Solution:
We start with fX (x) = 42x5 (1 − x) for 0 < x < 1 and transformation Y = X 3 .
1. Note: that y = x3 = g(x) is monotone.
2. Note: Y = (0, 1).
Based on the observations we can conclude we can use the transformation method.
Our first step is to find the inverse g −1 (y) = y 1/3 .
d −1
Second we find dy g (y) = dy d 1/3
y = 13 y −2/3 .
d −1 d −1
Since y > 0, we know that dy g (y) = dy g (y) for 0 < y < 1.
4
d −1
fY (y) = fX (g −1 (y)) g (y)
dy
1
fY (y) = fX (y 1/3 ) y −2/3
3
1
= 42y 5/3 (1 − y 1/3 ) y −2/3
3
= 14y(1 − y 1/3 )
= 14y − 144/3
Solution:
We need to check three things 1. limx→−∞ Fx = 0,limx→∞ Fx = 1 2. non-decreasing 3. right continuous.
limx→0 1 − e−x = 0
limx→∞ 1 − e−x = 1
−x
d
dx Fx = e which is greater than zero for x > 0 therefore FX (x) is non-decreasing. 1 − e−x is continuous.
b)
FX (x) = y = 1 − e−x
1 − y = e−x
log(1 − y) = −x
− log(1 − y) = x
FY (y) = − log(1 − y)
b. Differential the moment-generation function to find E(Y ),E(Y 2 ) and the V ar(Y )
Solution:
The mfg can be found by
n
X n x
MX (t) = ext p (1 − p)n−x
x
n
X n
= (pet )x (1 − p)n−x
x
n
X n x n−x
apply binomial formula u v = (u + v)n = (pet + (1 − p)n
x
5
b.) b. Differential the moment-generation function to find E(Y ),E(Y 2 ) and the V ar(Y )
d
Find dt MY (t) t=0 .
d d
MY (t) = (pet + (1 − p)n
dt dt
= n(pet + 1 − p)n−1 pet
Evaluate this at t = 0 to find E(Y )
d2 d
MY (t) = n(pet + 1 − p)n−1 pet
dt2 dt
= n(n − 1)(pet + 1 − p)n−2 pet · pet + n(pet + 1 − p)n−1 pet
= net p(pet + 1 − p)n−2 (n − 1)pet + (pet + 1 − p)
= np(np + (1 − p)
Now
V ar(Y ) = E[Y 2 ] − E[Y ]2
= (np)2 + np − np2 − (np)2
= np − np2