#include #include #include #include #include using namespace std; using namespace Eigen; int main( int argc, char **argv){ if(argc != 3){ cout << "Usage :\n"; cout << "\t Max # of samples ?\n"; cout << "\t order of H?\n"; exit(0); } /* Read the problem paremater */ unsigned N = atoi(argv[1]); //Number of MC samples unsigned P = atoi(argv[2]); P++; //Max order P of the Taylor expansion Hp of exp(x) std::default_random_engine generator; //Create pseudo random number generator std::uniform_real_distribution Unif(0,1.); //and uniform distribution in [0,1] VectorXd EofHP_ex = VectorXd::Zero(P); //Vector of exact means of Hp for p=0, P EofHP_ex(0) = 1; double xx = 1.; for(unsigned p=1; pnext){ //Report convergence VectorXd Error = MCSum/(double)(i) + EofHP_ex; //MC estimator E(F-Hp) + E(Hp) fprintf(out,"%d ",i); for(unsigned p=0; p