Question: Please answer both parts using R code: Use the the inverse transformation method to generate a discrete random variable X with P(X = 1) =
Please answer both parts using R code:
Use the the inverse transformation method to generate a discrete random variable X with P(X = 1) = 0.1, P(X = 2) = 0.2, P(X = 3) = 0.3, and P(X = 4) = 0.4.
a) Write a function that inputs an integer n (sample size, i.e., number of observations) and outputs a vector X of length n. The components of X are from {1, 2, 3, 4}.
b) Use set.seed(32951), let n = 100. Calculate the mean and variance of the generated random variable X.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
