Monte Carlo integration by Vegas

Brute force Monte Carlo

First we will implement the simple Monte Carlo method.

We used here a simple trick to avoid overflow, i.e.,

\begin{eqnarray} \sqrt{\frac{\langle f^2\rangle-\langle f\rangle^2}{N}} = \sqrt{\frac{(\sqrt{\langle f^2\rangle}-\langle f\rangle)(\sqrt{\langle f^2\rangle}+\langle f\rangle)}{N}} \end{eqnarray}

Vegas

First we define the grid points $g(x)$. At the beginning, we just set $g(x)=x$.

Update the class Grid, so that it can refine the grid