diff options
| author | Bertrand <bertrand.horel@gmail.com> | 2016-02-16 22:32:08 +0000 |
|---|---|---|
| committer | Bertrand <bertrand.horel@gmail.com> | 2016-02-16 22:32:08 +0000 |
| commit | a9b57e0fc0801530f26afa76dcc7ba0c4ec54c19 (patch) | |
| tree | e4d8f68ecfe3a5da6676228ba4dc67340f812a6c /option.cpp | |
| parent | 6b07d76c512c5450ce34fd6f2f8483c395a24ea2 (diff) | |
| download | projet_C++-a9b57e0fc0801530f26afa76dcc7ba0c4ec54c19.tar.gz | |
correction bugg
Diffstat (limited to 'option.cpp')
| -rw-r--r-- | option.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -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; |
