using r coding
Let Y be the random variable defined by: Y = 1 with probability 0.10, 5 with probability 0.20 ,10 with probability 0.40, 15 with probability 0.20, 19 with probability 0.10
)
Write an R program to simulate NOBS observations of the random variable Y. For NOBS=10000, find the sample mean and sample standard deviation.
Write an R program to simulate NGAME games. Using the sample results for a simulation with NGAME = 40000
Here we have the discrete distribution of defined as
So we can see that the theoretical mean is
So we can see that the theoretical standard deviation is
The R code for simulating NOBS = 10000 samples from the above distribution is given below:
NOBS <- 10000
Y <- sample(c(1,5,10,15,19), size = NOBS, prob =
c(0.1,0.2,0.4,0.2,0.1), replace = TRUE)
mean(Y)
sd(Y)
The the sample mean is 10.0704 and sample standard deviation is 5.110093.
Both matches with the theoretical values.
Get Answers For Free
Most questions answered within 1 hours.