In: Statistics and Probability
Create a die, which will roll a 6 with probability of 50% and all other numbers (1-5) with equal probability. What is E(Y) if Y was the outcome of that die? and X is the result of the fair die.
sd(Y)
var(X-2Y)
Please write the code in R
The die is a biased die with 50% probability of getting a 6. The remaining numbers 1-5 can be obtained equally. Hence the probability of each of these numbers is 50/5 = 10%.
Thus, the random variable Y = {1, 2, 3, 4, 5, 6}
And the probabilities are given by P = {0.1, 0.1, 0.1, 0.1, 0.1, 0.5}.
The expectation of the random variable is obtained as the sum of the products of values assumed by the random variable and the probabilities of each of these values.
Therefore, E(Y) = 4.5.
Similarly, we can calculate the expectation of Y^2.
The variance is given as
The standard deviation is obtained as the square root of the variance.
In R language, the code can be written as:
Y = 1:6 # Random variable P = c(0.1, 0.1, 0.1, 0.1, 0.1, 0.5) # Probabilities # Expectation E = sum(P*Y) E2 = sum(P*Y*Y) # Variance and Standard Deviation Var = E2 - E**2 Std = sqrt(Var)