aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp19
-rw-r--r--src/stratified_sampling.hpp5
2 files changed, 18 insertions, 6 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 88f3737..fb6df08 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -60,10 +60,21 @@ x = 1.64*S.estimator().second;
vector<double> p(100, 0.01);
asian_option A(0.05, 1.0, 50, 0.1, d, 45);
f_mu G(mu,A);
- multi_gaussian_truncated MG(q[50],q[51], u);
- for(int i=0; i<10; i++){
- std::cout<<G(MG())<<std::endl;
- }
+ std::vector<compose_t <f_mu, multi_gaussian_truncated> > X;
+ X.push_back(compose(G, multi_gaussian_truncated(GSL_NEGINF,q[0], u)));
+ for(int i=1; i<100; i++) {
+ X.push_back(compose(G, multi_gaussian_truncated(q[i-1],q[i], u)));
+ }
+ for(int i=0; i<100; i=i+10){
+ std::cout<<X[i]()<<endl;
+ }
+ 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;
+ //~ }
}
diff --git a/src/stratified_sampling.hpp b/src/stratified_sampling.hpp
index ed53b6d..c04369e 100644
--- a/src/stratified_sampling.hpp
+++ b/src/stratified_sampling.hpp
@@ -141,8 +141,9 @@ void stratified_sampling<L>::draw(int N) {
m=0;
s=0;
for(int j=0;j<M[i];j++){
- m=m+X[i]();
- s=s+X[i].current()*X[i].current();
+ double temp = X[i]();
+ m=m+temp;
+ s=s+temp*temp;
}
oldmean=mean[i];
mean[i]=(mean[i]*cumM[i]+m)/(cumM[i]+M[i]);