Probably the code below is not the best looking, but it gets the job done. At least that is what I thought. I encounter a problem when I try to use a number of sample points that is bigger than 250,0000. I do not really know how to go about this.
The only thing that I have tried was switching the type of the variable from int to long.
double MonteCarlo(){
const long N = 250000;
double GenR[NumPoints],apprx;
static double result[1];
double sum = 0;
default_random_engine generator;
uniform_real_distribution<double> distribution(0.0,1.0);
for(int i=0; i<=NumPoints; i++){
randGen[i] = distribution(generator);
sum += 4*exp(16*pow(GenR[i],2)-12*GenR[i]+2);
}
apprx = sum/NumPoints;
return apprx;
}