Calculates the integral of a given function using Monte Carlo techniques