I'm trying to evaluate $$I=\int_{0}^\pi xe^{-x}sin(x) dx$$
by doing the Monte Carlo simulation in R with the following estimator
$$\hat I=\frac{1}{n}\sum_{i=1}^n xe^{-x}sin(x)$$
where X1, X2,...,Xn are i.i.d. continuous random variables of $Unif(0, \pi)$.
When I integrate $I$, I get $I=0.5895$.
Now, when I try to estimate $\hat I$ in R with n=10 000 with the following instructions:
x<-runif(10000, min = 0, max = pi)
mean(x*exp(-x)*sin(x))
$= 0.1876$
Is it normal it is so far off from the true value? Am I missing something when I type it in R?
Thanks in advance.
Hint: multiplying your answer by $\pi$ gives the actual integral's value.