diff options
| -rw-r--r-- | src/projet.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/projet.cpp b/src/projet.cpp index 4a5889e..a89c793 100644 --- a/src/projet.cpp +++ b/src/projet.cpp @@ -1,4 +1,5 @@ #include <iostream> +#include <fstream> #include <vector> #include <gsl/gsl_cdf.h> #include <gsl/gsl_math.h> @@ -109,14 +110,31 @@ void exemple2_rqmc() { } }; +int make_table(vector< vector<double> > data1, vector< vector<double> > data2) { + std::fstream fs("doc/table.tex", std::fstream::out);; + fs<<R"(\begin{tabular}{|l|ll|ll|l|})"<<std::endl; + fs<<R"(\hline)"<<endl; + fs<<"N"<<" & "<<R"($\mu_{strat}$)"<<" & "<<R"($\mu_{rqmc}$)"<<" & "<<R"($IC_{strat}$)"<<" & "<<R"($IC_{rqmc}$)"<<" & "<<"Ratio strat/rqmc"<<R"(\\ \hline)"<<std::endl; + for (int i=0; i< 4; i++) { + double ic_strat = 1.95996*sqrt(data1[i][2]/(double) data1[i][0]); + fs<<data1[i][0]<<"&"<<data1[i][1]<<"&"<<data2[i][0]<<"&"<<ic_strat<<"&"<<data2[i][2]/2<<"&"<<ic_strat/(data2[i][2]/2)<<R"(\\ \hline)"<<std::endl; + } + fs<<R"(\end{tabular})"<<std::endl; + fs.close(); + return 0; +} int main() { init_alea(1); + cout<<gsl_cdf_gaussian_Pinv(0.975,1)<<endl; cout<<"Stratified_sampling sur l'exemple 1 de la normale"<<endl; - exemple1_stratified(); + vector< vector<double> > data1 = exemple1_stratified(); cout<<"Randomised quasi Monte-Carlo sur l'exemple 1 de la normale"<<endl; - exemple1_rqmc(); + vector< vector<double> > data2 = exemple1_rqmc(); + make_table(data1, data2); return 0; } + + |
