MC.Phi: Monte Carlo integration with antithetic variables

Description Usage Arguments Value Examples

View source: R/ex.R

Description

This function is defined to estimate integral(frac(e^-x,1+x^2)*dx,0,1) and test the effect of antithetic variables in variance reduction.

Usage

1
MC.Phi(R = 10000, anti = TRUE)

Arguments

R

number of generated samples to estimate the integration

anti

use antithetic variables or not

Value

The numerical estimation of integral(frac(e^-x,1+x^2)*dx,0,1)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
set.seed(2222)
m=1000;
MC.de=MC=numeric(m)
for (i in 1:m){
 MC.de[i]=MC.Phi(R=1000)
 MC[i]=MC.Phi(R=1000,anti=FALSE)
 }
print("Approximate reduction in variance: ");(var(MC)-var(MC.de))/var(MC)

## End(Not run)

XixuHu/SC19090 documentation built on Jan. 2, 2020, 8:40 p.m.