aboutsummaryrefslogtreecommitdiffstats
path: root/src/projet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/projet.cpp')
-rw-r--r--src/projet.cpp51
1 files changed, 40 insertions, 11 deletions
diff --git a/src/projet.cpp b/src/projet.cpp
index 980ef98..57f6b91 100644
--- a/src/projet.cpp
+++ b/src/projet.cpp
@@ -9,8 +9,7 @@
using namespace std;
-
-void exemple1() {
+void exemple1_stratified() {
vector<double> q = quantile_norm(10, 1);
vector<double> p(10, 0.1);
vector<gaussian_truncated> rvar;
@@ -35,7 +34,7 @@ void exemple1() {
};
- void exemple2 (){
+ void exemple2_stratified (){
int d= 16;
std::vector<double> mu(d);
mu = argmax(0.05, 1.0, 50, 0.1, 45, d);
@@ -62,18 +61,48 @@ void exemple1() {
stratified_sampling<compose_t <f_mu, multi_gaussian_truncated> > S(p, X);
S.draw(1000);
cout<<"l'estimateur de la moyenne est :"<<S.estimator().first<<endl;
- //~ compose_t <f_mu, multi_gaussian_truncated> X = compose(G,MG);
- //~ for(int i=0; i<10; i++){
- //~ std::cout<<X()<<std::endl;
- //~ }
}
+void exemple2_rqmc() {
+ asian_option A(0.05, 1.0, 50.0, 0.1, 16, 45);
+ int N= 10000;
+
+ int d =16;
+
+
+ std::vector<double> result(3);
+ result = quasi_mean(100, quasi_option<asian_option, sobol> (N, d, A));
+ for(int i =0; i<3; i++){
+ std::cout<<result[i]<<std::endl;
+ }
+
+ std::vector<double> result2(3);
+ result2 = quasi_mean(100, quasi_option<asian_option, halton> (N, d, A));
+ for(int i =0; i<3; i++){
+ std::cout<<result2[i]<<std::endl;
+ }
+};
+
+struct first:public std::unary_function<std::vector<double>, double>
+{ double operator()(std::vector<double> X){return X[0];}
+};
+
+void exemple1_rqmc(){
+ int N = 100;
+ first f; //comme quasi_gaussian retourne un vecteur, on doit composer avec f pour avoir le double QG()[0]
+ std::vector<double> result(3);
+ result = quasi_mean (100,quasi_option<struct first, sobol> (N, 1, f));
+ for(int i =0; i<3; i++){
+ std::cout<<result[i]<<std::endl;
+ }
+};
int main()
{
init_alea(1);
- exemple1();
- //exemple2();
-
- return 0;
+ //exemple2_rqmc();
+ //exemple1_stratified();
+ exemple1_rqmc();
+ return 0;
+
}