Text this: An Optimal Monte Carlo Algorithm for a Class of Multidimensional Integrals