Assume X is distributed TRIA(4, 9, 10). Estimate E[X2 ] using Monte Carlo simulation
The value of E[X^2]=60.59851
Here we use Monte Carlo simulation using R
The R-code is N=10000
X={}
a=4;b=10;m=9
F_m=(m-a)/(b-a)
for( i in 1:N){
set.seed(i)
U=runif(1)
if(U<F_m) X[i]=a+sqrt(U*(b-a)*(m-a)) else
X[i]=b-sqrt((1-U)*(b-a)*(b-m))}
E_X=mean(X)
E_X2=mean(X^2)
E_X2
The Output of R-code is > N=10000
> X={}
> a=4;b=10;m=9
> F_m=(m-a)/(b-a)
> for( i in 1:N){
+ set.seed(i)
+ U=runif(1)
+ if(U<F_m) X[i]=a+sqrt(U*(b-a)*(m-a)) else
X[i]=b-sqrt((1-U)*(b-a)*(b-m))}
> E_X=mean(X)
> E_X2=mean(X^2)
> E_X2
[1] 60.59851
Get Answers For Free
Most questions answered within 1 hours.