Antithetic method for monte carlo when bounds of the integral are infinite I wanted to apply Monte Carlo with antithetic variables to estimate $\int_{0}^{\infty} e^{-x} \,dx$ (equal to 1). I used this R code.
a <- runif(1000)
f <- function(x) exp(-x)
x <- f(a)
y <- f(1-a)
mean((x+y)/2)

However, it returned 0.632577961884066, which is not 1. I am really confused.

Your code does not correspond to your description of the problem, so it is not surprising that you are not getting the results you expected. The integral you want to approximate is
$$
\int_0^\infty e^{-x} \, dx
$$
but in your code, you sample the a values from $\mathcal{U}(0, 1)$ distribution, I'd argue that $1$ is much less than infinity. As you can see below, the integral in $(0, 1)$ is indeed close to what you've got
> integrate(\(x) exp(-x), 0, 1)
0.6321206 with absolute error < 7e-15
> pexp(1)
[1] 0.6321206

The basic Monte Carlo approximation of the integral samples the $x$ values from the uniform distribution $\mathcal{U}(a, b)$ with the bounds corresponding to the integration bounds, and approximates the integral with
$$
\frac{b-a}{N} \sum_{i=1}^N f(x)
$$
Let's pick $1000$ as a "high number" to approximate the infinity ($e^{-1000}$ would be close enough to zero), in such a case the result is
> n <- 1000000
> a <- 0
> b <- 1000
> exp(-b)
[1] 0
> (b-a)/n * sum(exp(-runif(n, a, b)))
[1] 1.008663
> (b-a)/n * sum(exp(-runif(n, a, b)))
[1] 0.989083

You cannot use $\mathcal{U}(0, 1)$ for sampling here and use 1-a as the antithetic variable.
