Suppose X is a random variable taking on possible values 0,2,4 with respective probabilities .5, .3, and .2. Y is a random variable independent from X taking on possible values 1,3,5 with respective probabilities .2, .2, and .6. Use R to determine the following.
a) Find the expected value of Y.
b) Find the variance of Y.
c) Find the expected value of Y4 .
PLEASE SHOW ANSWER IN R SCRIPT
The R script is
X=c(0,2,4)
P1=c(0.5,0.3,0.2)
Y=c(1,3,5)
P2=c(0.2,0.2,0.6)
#Expected Value of Y
Ey=sum(Y*P2)
Ey
# Expected Value of Y is 3.8
#Variance of Y
Vy=sum((Y-Ey)^2*P2)
Vy
#Variance of Y is 2.56
# Expected value of Y^4
Ey4=sum(Y^4*P2)
Ey4
# Expected value of Y^4 is 391.4
The R Code is
X=c(0,2,4)
P1=c(0.5,0.3,0.2)
Y=c(1,3,5)
P2=c(0.2,0.2,0.6)
#Expected Value of Y
Ey=sum(Y*P2)
Ey
The Output of code is
>X=c(0,2,4)
>P1=c(0.5,0.3,0.2)
>Y=c(1,3,5)
>P2=c(0.2,0.2,0.6)
>#Expected Value of Y
>Ey=sum(Y*P2)
>Ey
[1] 3.8
>#Variance of Y
>Vy=sum((Y-Ey)^2*P2)
>Vy
[1] 2.56
># Expected value of Y^4
>Ey4=sum(Y^4*P2)
>Ey4
[1] 391.4
Get Answers For Free
Most questions answered within 1 hours.