1
$\begingroup$

Let $$ f(x) = \sqrt{1-x^2}, \quad I = \int \limits_0^1 f(x) dx. $$

We consider the following estimator of I: $$ \hat{I}_n = \frac{1}{n} \sum \limits_{i=1}^n f(X_i), $$ where $X_1, X_2, ...$ are iid $U(0,1)$.

The task is to calculate $Var(\hat{I}_n)$.

My approach: $$ Var(f(X_1)) = E[f(X_1)]^2 - (Ef(X_1))^2 = \int_0^1 1 - x^2 dx - \Big{(} \int_0^1 \sqrt{1 - x^2} dx \Big{)}^2 = \frac{2}{3} - \Big{(}\frac{\pi}{4}\Big{)}^2 $$ $$ Var(\hat{I}_n) = Var\Big{(} \frac{1}{n} \sum \limits_{i=1}^n f(X_i) \Big{)} = \frac{1}{n^2} Var\Big{(}\sum \limits_{i=1}^n f(X_i) \Big{)} = \frac{1}{n^2} \sum \limits_{i=1}^n Var(f(X_i)) = \frac{1}{n^2} n \Big{(}\frac{2}{3} - \Big{(}\frac{\pi}{4}\Big{)}^2 \Big{)} $$

Is that correct?

My other question is how to estimate $Var(\hat{I}_n)$ using simulation?

n <- 100000
U <- runif(n)
X <- sqrt(1-U^2)
I <- mean(X)

Here I is the estimator of the itegral and var(X) gives me approximately $\frac{2}{3} - \Big{(}\frac{\pi}{4}\Big{)}^2$

But when I try to estimate $Var(I_n)$

w <-c ()
for(i in 1:1000){
  U <- runif(n)
  X <- sqrt(1-U^2)
  I <- mean(X)
  w <- c(w,I)
}

Here, var(w) is approximately 5.01359e-07. If I use the formula devired above $Var(\hat{I}_n) = \frac{1}{n} \Big{(}\frac{2}{3} - \Big{(}\frac{\pi}{4}\Big{)}^2 \Big{)} \approx 4.981639e-05$

Where is the mistake?

$\endgroup$

1 Answer 1

2
$\begingroup$

Your calculations seem correct. Since $n$ is large, and iterate only 1000 times in the outer loop, the variance you get is fluctuating a lot around small numbers. Try the following, where the variance is better noticeable:

n <- 10
w <-c ()
for(i in 1:50000){
  U <- runif(n)
  X <- sqrt(1-U^2)
  I <- mean(X)
  w <- c(w,I)
}
var(w)
(2/3 - (pi/4)^2)/n
$\endgroup$
3
  • 1
    $\begingroup$ I see :) great :D Thank you very much! $\endgroup$ Jun 5, 2020 at 16:44
  • $\begingroup$ It's also quite interesting that in order to calculate the variance of your estimator, we actually use the result of the integral. Then, what was the point in estimating it :) $\endgroup$
    – gunes
    Jun 5, 2020 at 16:45
  • $\begingroup$ That's true :D I did not notice that! The sad answer is: in order to prepare to the exam :) $\endgroup$ Jun 5, 2020 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.