From 778a4f66c76a02a2c800e0d4bb8b05a03b14497f Mon Sep 17 00:00:00 2001 From: Bertrand Date: Thu, 21 Apr 2016 00:23:19 +0200 Subject: modif argmax --- src/opti.cpp | 2 +- src/projet.cpp | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/opti.cpp b/src/opti.cpp index 7f838e9..efe5643 100644 --- a/src/opti.cpp +++ b/src/opti.cpp @@ -34,7 +34,7 @@ std::vector argmax(double r, double T, double S0, double V, double K, in opt.set_xtol_rel(1e-4); - std::vector x(d,0); + std::vector x(d,1); std::vector g(0); double maxf; diff --git a/src/projet.cpp b/src/projet.cpp index 205e362..241ab0b 100644 --- a/src/projet.cpp +++ b/src/projet.cpp @@ -77,33 +77,37 @@ std::vector normalize (std::vector mu) { vector > exemple2_stratified (int d){ std::vector mu(d); - vector K = {45, 50, 55}; + vector K = {45, 50, 55}; vector N = {100000, 400000, 500000}; vector< vector > data(3); + vector q = quantile_norm(100, 1); + vector p(100, 0.01); + double r = 0.05; + double T = 1.0; + double S0 = 50; + double V = 0.1; + typedef compose_t, multi_gaussian_truncated> tilted_option; for (int i=0; i<3; i++){ - mu = argmax(0.05, 1.0, 50, 0.1, K[i], d); + mu = argmax(r, T, S0, V, K[i], d); std::vector u(d); u = normalize(mu); - vector q = quantile_norm(100, 1); - vector p(100, 0.01); - asian_option A(0.05, 1.0, 50, 0.1, K[i], true); + asian_option A(r, T, S0, V, K[i], true); exponential_tilt G(mu, A); - typedef compose_t, multi_gaussian_truncated> tilted_option; std::vector X; X.push_back(compose(G, multi_gaussian_truncated(GSL_NEGINF,q[0], u))); - for(int j=1; j<100; i++) { + for(int j=1; j<100; j++) { X.push_back(compose(G, multi_gaussian_truncated(q[j-1],q[j], u))); } stratified_sampling S(p, X); vector r(3, 0); - for (int j=0; j<3; i++){ + for (int j=0; j<3; j++){ S.draw(N[j]); } r[0] = K[i]; r[1] = S.estimator().first; r[2] = S.estimator().second; data[i] = r; - for(int j=0; i<3; i++){cout< normalize (std::vector mu) { void exemple2_rqmc(int d) { asian_option A(0.05, 1.0, 50.0, 0.1, 45,true); int N= 10000; - std::vector result(3); result = monte_carlo(100, quasi_mean (N, d, A)); @@ -143,7 +146,7 @@ int make_table1(vector< vector > data1, vector< vector > data2) int main() { - init_alea(1); + init_alea(2); //~ cout< > data1 = exemple1_stratified(); -- cgit v1.2.3-70-g09d2