The fundamental validation of the Monte Carlo method is the Law of Large Numbers: when $𝔼[X]$ does exist, meaning when $𝔼[|X|]$ is finite, then the empirical average$$\bar{X}_T=\frac{1}{T}\sum_{t=1}^T X_t$$converges almost surely to $𝔼[X]$.
When the expectation $𝔼[X]$ does not exist, meaning$$\int |x|f(x)\text{d}x=+\infty$$there is no guarantee for the empirical average to converge, see e.g. the case of the iid standard Cauchy sequence, when $\bar{X}_T$ remains a standard Cauchy for all $T$'s. But there also exist cases when it converges, as discussed in another XV question[another XV question][1]:
Counter-examples provided in Wikipedia[Wikipedia][2] are
- $X=\sin(Z)\exp\{Z\}/Z$ when $Z\sim\mathcal{E}xp(1)$, with $\mu=\pi/2$
- $X=2^Z(-1)^Z/z$ when $Z\sim\mathcal{G}(1/2)$, with $\mu=-\log(2)$
- $X\sim F(x)$ with $$F(x)=\mathbb{I}_{x\ge e}-\frac{e\mathbb{I}_{x\ge e}}{2x\log(x)}-\frac{e\mathbb{I}_{x\le-e}}{2x\log(-x)}+\frac{\mathbb{I}_{-e\le x\le e}}{2}$$with $\mu=0$
[in the sense that the rv's have no expectation but there exists a limit $\mu$$-$in probability if not a.s.$-$for the sample average $\bar{X}_n$].
See also this quite informative answer[this quite informative answer][3] on XV.
Now, if you take an easily divergent example such as the Pareto $\cal{P}(1/2,4)$ distribution $$f(x)=x^{-3/2}\mathbb{I}_{x>4}$$ simulating this distribution is equivalent to turn a uniform $U$ into $4/U^2$. The mean of the Pareto $\cal{P}(1/2,4)$ distribution is infinite: $$\int_4^\infty x^{-1/2}\text{d}x=+\infty$$But a Monte Carlo experiment does not exhibit a lack of convergence or convergence to $+\infty$, simply that the average can take arbitrarily large values after any number of iterations, as demonstrated on this experiment with 10⁶ simulations, repeated 10² times:
[![enter image description here][4]][4]
Note also that, in the case of positive rv's like the Pareto $\cal{P}(1/2,4)$ distribution above, $\bar{X}_T$ does not have to converge to infinity if $\mathbb{E}[X]=\infty$. Indeed by Chebychev's inequality, \begin{align*} \mathbb{P}(\bar{X}_T\ge a) &\le \frac{1}{a^\epsilon}\int_{x>a} x^\epsilon \text{d}\mathbb{P}^{\bar{X}_T}(x) \end{align*} which may be finite for $\epsilon>0$ small enough, in which case the rhs probability goes to zero as $a$ goes to infinity. [1]: https://stats.stackexchange.com/a/328039/7224 [2]: https://en.wikipedia.org/wiki/Law_of_large_numbers#Differences_between_the_weak_law_and_the_strong_law [3]: https://stats.stackexchange.com/a/29891/7224 [4]: https://i.sstatic.net/i3z8S.jpg