aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBertrand <bertrand.horel@gmail.com>2016-02-16 22:32:08 +0000
committerBertrand <bertrand.horel@gmail.com>2016-02-16 22:32:08 +0000
commita9b57e0fc0801530f26afa76dcc7ba0c4ec54c19 (patch)
treee4d8f68ecfe3a5da6676228ba4dc67340f812a6c
parent6b07d76c512c5450ce34fd6f2f8483c395a24ea2 (diff)
downloadprojet_C++-a9b57e0fc0801530f26afa76dcc7ba0c4ec54c19.tar.gz
correction bugg
-rw-r--r--option.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/option.cpp b/option.cpp
index 8229730..63c7a05 100644
--- a/option.cpp
+++ b/option.cpp
@@ -43,14 +43,16 @@ struct quasi_option : public generator<double>
quasi_option(int n, int d, Fct payoff) : n(n), d(d), payoff(payoff), U(0,1), s(d), seed(d) {};
double operator()() {
- for(int i=0; i<d; i++){
- seed[i]=U();
- }
std::vector<double> X(d);
double sum =0;
- X = s();
for (int i=0; i<n; i++){
- X[i] = gsl_cdf_gaussian_Pinv(frac_part(seed[i]+X[i]), 1);
+ X=s();
+ //std::cout<<X[i]<<std::endl;
+ for(int i=0; i<d; i++){
+ seed[i]=U();
+ X[i] = gsl_cdf_gaussian_Pinv(frac_part(seed[i]+X[i]), 1);
+ }
+ //std::cout<<X[i]<<std::endl;
}
sum += payoff(X);
return sum/n;
@@ -67,7 +69,7 @@ struct quasi_option : public generator<double>
int main(){
init_alea(1);
asian_option A(0.05, 1.0, 50.0, 0.1, 16, 45);
- int N= 1000;
+ int N= 10000;
int d =16;