6. 18 points My Notes Ask Your Teache Suppose X is a random variable taking on p
ID: 3356514 • Letter: 6
Question
6. 18 points My Notes Ask Your Teache Suppose X is a random variable taking on possible values 1,2,4 with respective probabilites .1, .2, and .7. Y is a random variable independent from X taking on possible values 1,2,5 with respective probabilites .3, .1, and .6. Use R to determine the following. a) Find the probability P(X + Y = 3) b) Find the expected value of X. c) Find the variance of X d) Find the expected value of Y e) Find the variance of Y f) Find the expected value of X*Y. (i.e. X times Y) 9) Find the expected value of 5X 3Y. h) Find the variance of 5X - 3Y i) Copy your R script for the above into the text box here.Explanation / Answer
a)
Below is the code if R along with the comments to explain the code.
P = 0 # Intialize probability value
X = c(1,2,4) # Load X
PX = c(0.1,0.2,0.7) # Load probability of X
Y = c(1,2,5) # Load Y
PY = c(0.3,0.1,0.6) # Load probability of Y
for (x in 1:3) {
for (y in 1:3) {
if ((X[x] + Y[y]) == 3) { # Check for X+Y = 3
P = P + PX[x]*PY[y] # If consitions match multiply the prob of X and Y and add
}
}
}
I got the answer P as 0.07
So, P(X + Y= 3) = 0.07
b)
Use code
X = c(1,2,4) # Load X
PX = c(0.1,0.2,0.7) # Load probability of X
EX = sum(X*PX)
to find the expected value of X.
The answer is E(X) = 3.3
(c)
X = c(1,2,4) # Load X
PX = c(0.1,0.2,0.7) # Load probability of X
EX = sum(X*PX) # Sum of product of X and PX
EX2 = sum(X^2*PX) # Sum of product of X^2 and PX
VarX = EX2 - EX^2 # Difference of EX2 and EX^2
I got the answer as, VarX = 1.21
So, Variance of X is 1.21
(d)
The code for mean and variance of Y is below.
R code -
Y = c(1,2,5) # Load Y
PY = c(0.3,0.1,0.6) # Load probability of Y
EY = sum(Y*PY) # Sum of product of Y and PY
EY2 = sum(Y^2*PY) # Sum of product of Y^2 and PY
VarY = EY2 - EY^2 # Difference of EY2 and EY
The mean of Y (EY) is 3.5
(e)
Variance of Y (VarY) is 3.45
(f) As X and Y are independent, the expected value of X*Y is given as,
R code -
EXY = sum(X*Y*PX*PY)
expected value of X*Y is 8.51
(g)
The expected value of 5X+3Y is 27
R code -
E = 5*EX + 3*EY
(h)
The variance of 5X-3Y is 61.3
R code -
V = 5^2*VarX + 3^2*VarY
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.