In: Statistics and Probability
5. Use either R or Excel for the following. Provide the formulas or code that you are using. Let x1 be a random variable that is N(100, 225). Let x2 be a random variable that is U(50,150) and let x3 be a random variable that is U(500,1500).
Set Y = (X1)(X2)/ (X3)
a) Use R to create 500 random numbers of each type (X1, X2, X3 and Y).
b) Estimate P(0.1 < Y < 0.25)
c) Estimate E(Y) and the Standard deviation of Y based on the random numbers.
d) Based on the simulation, what is the maximum value of Y
e) Create a histogram for Y.
Attached is the R code marked in Bold
# To draw numbers from N(100,225)
n <- 500
x1 <- rnorm(n, mean = 100, sd = 225)
# To draw numbers from U(50,150)
x2 <- runif(n, min = 50, max = 150)
# To draw numbers from U(500,1500)
x3 <- runif(n, min = 500, max = 1500)
y <- (x1*x2)/x3
y_prob <- y[y>0.1 & y < 0.25]
# Probability (0.1<y<0.25)
p <- length(y_prob)/n
# E(y)
y_bar <- mean(y)
# Standard deviation of y
sd <- sd(y)
max(y)
# Histogram of y
hist(y,freq = FALSE)
print(y_bar)
print(sd)
print(max(y))
print(p)
Ans
E(y) =10.90617
Standard deviation of y = 26.50636
P(0.1<y<0.25) = 0.002
Maximum of y =107.8512