Generate two values for Normal distribution with mean as 20 and variance as 9, and 2 values for Binomial distribution with P as 0.2.
Here we use R
R-code is
mean=60;var=9
U=runif(2);U
#[1] 0.03752404 0.52682849
X1=mean+sqrt(var)*(sqrt(-2*log(U[1]))*cos(2*pi*U[2]))
X2=mean+sqrt(var)*(sqrt(-2*log(U[1]))*sin(2*pi*U[2]))
print(c(X1,X2))
#[1] 52.42196 58.71034
#Two values for normal distribution with mean=60 & var=9 is X1=52.42196,X2=58.71034
X={}
P=0.2
for(i in 1:2) if(U[i]<=P) X[i]=1 else X[i]=0
print(X)
#[1] 1 0
#Two values for binomial distribution with n=1 & P=0.2 is X1=1,X2=0
Get Answers For Free
Most questions answered within 1 hours.