aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorBertrand <bertrand.horel@gmail.com>2016-02-21 14:26:26 +0000
committerBertrand <bertrand.horel@gmail.com>2016-02-21 14:26:26 +0000
commit045fc28b3432e07f3d9702150a56f21e7650f12a (patch)
tree6465e412bdb9ac2c45eaa4434a9897925e620622 /src/main.cpp
parentbb210dbdc524ad51927a9932638078ddb1383bb6 (diff)
downloadprojet_C++-045fc28b3432e07f3d9702150a56f21e7650f12a.tar.gz
modif du Makefile et de var_alea et autres
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp67
1 files changed, 36 insertions, 31 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f81f1dd..f6e998a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -17,37 +17,42 @@ vector<double> quantile_norm(int n, double sigma){
return q;
}
+void exemple1() {
+gsl_rng_env_setup();
+vector<double> q = quantile_norm(10, 1);
+vector<double> p(10, 0.1);
+vector<gaussian_truncated> rvar;
+rvar.push_back(gaussian_truncated(GSL_NEGINF, q[0],0,1,0));
+for (int i=1; i<10; i++){
+ rvar.push_back(gaussian_truncated(q[i-1], q[i],0,1,i));
+};
+stratified_sampling<gaussian_truncated> S(p,rvar);
+S.draw(100);
+double x = 1.64*S.estimator().second;
+ cout<<"l'estimateur de la moyenne est :"<<S.estimator().first<<endl;
+ cout<<"Son intervalle de confiance à 95% est :"<<"["<<S.estimator().first-(x/10)<<" ,"<<S.estimator().first+(x/10)<<"]"<<endl;
+S.draw(1000);
+x = 1.64*S.estimator().second;
+ cout<<"l'estimateur de la moyenne est :"<<S.estimator().first<<endl;
+ cout<<"Son intervalle de confiance à 95% est :"<<"["<<S.estimator().first-(x/sqrt(1100))<<" ,"<<S.estimator().first+(x/sqrt(1100))<<"]"<<endl;
+ S.draw(10000);
+ x = 1.64*S.estimator().second;
+ cout<<"l'estimateur de la moyenne est :"<<S.estimator().first<<endl;
+ cout<<"Son intervalle de confiance à 95% est :"<<"["<<S.estimator().first-(x/sqrt(11100))<<" ,"<<S.estimator().first+(x/sqrt(11100))<<"]"<<endl;
+
+};
+
+
+
int main()
-{
- //--- GSL random init ---
- gsl_rng_env_setup();
- vector<double> q = quantile_norm(10, 1);
- vector<double> p(10, 0.1);
- vector<gaussian_truncated> rvar;
- rvar.push_back(gaussian_truncated(GSL_NEGINF, q[0],0,1,0));
- for (int i=1; i<10; i++){
- rvar.push_back(gaussian_truncated(q[i-1], q[i],0,1,i));
+{
+ std::vector<double> u {sqrt(0.2), sqrt(0.2), sqrt(0.2), sqrt(0.2), sqrt(0.2)};
+ multi_gaussian_truncated G(0, 2, u);
+ std::vector<double> r(5);
+ r = G();
+ for (int i=0; i<5; i++){
+ std::cout<<r[i]<<std::endl;
}
- stratified_sampling<gaussian_truncated> S(p,rvar);
- //S.update(100);
- S.draw(100);
- double x = 1.64*S.estimator().second;
- cout<<"l'estimateur de la moyenne est :"<<S.estimator().first<<endl;
- cout<<"Son intervalle de confiance à 95% est :"<<"["<<S.estimator().first-(x/10)<<" ,"<<S.estimator().first+(x/10)<<"]"<<endl;
- //S.update(1000);
- S.draw(1000);
- x = 1.64*S.estimator().second;
- cout<<"l'estimateur de la moyenne est :"<<S.estimator().first<<endl;
- cout<<"Son intervalle de confiance à 95% est :"<<"["<<S.estimator().first-(x/sqrt(1100))<<" ,"<<S.estimator().first+(x/sqrt(1100))<<"]"<<endl;
- //S.update(10000);
- S.draw(10000);
- x = 1.64*S.estimator().second;
- cout<<"l'estimateur de la moyenne est :"<<S.estimator().first<<endl;
- cout<<"Son intervalle de confiance à 95% est :"<<"["<<S.estimator().first-(x/sqrt(11100))<<" ,"<<S.estimator().first+(x/sqrt(11100))<<"]"<<endl;
-
- //~ S.draw();
- //~ for(int i=0;i<10;i++){
- //~ cout<<S.get_mean()[i]<<endl;
- //~ }
- return 0;
+
+ return 0;
}