From 19a56a000c683455d96ae577e844f0e4f60fe697 Mon Sep 17 00:00:00 2001 From: louisaslett Date: Mon, 11 Nov 2024 12:15:22 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20louisasl?= =?UTF-8?q?ett/mlmc@54def1aea2b579ef55a3e5d55d21efd440b25b6f=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- news/index.html | 1 + pkgdown.yml | 2 +- reference/mlmc.html | 2 +- search.json | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/news/index.html b/news/index.html index 89a4d61..4d435db 100644 --- a/news/index.html +++ b/news/index.html @@ -35,6 +35,7 @@

mlmc 2.1.1

mlmc 2.1.0

CRAN release: 2024-11-08

diff --git a/pkgdown.yml b/pkgdown.yml index 1dfa17a..eb55412 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -2,7 +2,7 @@ pandoc: 3.1.11 pkgdown: 2.1.1 pkgdown_sha: ~ articles: {} -last_built: 2024-11-10T18:10Z +last_built: 2024-11-11T11:50Z urls: reference: https://mlmc.louisaslett.com/reference article: https://mlmc.louisaslett.com/articles diff --git a/reference/mlmc.html b/reference/mlmc.html index 74618ec..4d37070 100644 --- a/reference/mlmc.html +++ b/reference/mlmc.html @@ -112,7 +112,7 @@

Argumentsparallel -

if an integer is supplied, R will fork parallel parallel processes and compute each level estimate in parallel.

+

if an integer is supplied, R will fork parallel parallel processes and spread the simulations required at each level as evenly as possible across all cores.

...
diff --git a/search.json b/search.json index 13cc381..a3a190c 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"https://mlmc.louisaslett.com/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Louis Aslett. Maintainer, author, translator. Mike Giles. Contributor. Tigran Nagapetyan. Contributor. Sebastian Vollmer. Contributor.","code":""},{"path":"https://mlmc.louisaslett.com/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Aslett L (2024). mlmc: Multi-Level Monte Carlo. R package version 2.1.1, https://github.com/louisaslett/mlmc, https://mlmc.louisaslett.com/.","code":"@Manual{, title = {mlmc: Multi-Level Monte Carlo}, author = {Louis Aslett}, year = {2024}, note = {R package version 2.1.1, https://github.com/louisaslett/mlmc}, url = {https://mlmc.louisaslett.com/}, }"},{"path":"https://mlmc.louisaslett.com/index.html","id":"mlmc-r-package-","dir":"","previous_headings":"","what":"Multi-Level Monte Carlo","title":"Multi-Level Monte Carlo","text":"implementation Multi-level Monte Carlo R. package builds original GPL-2 Matlab C++ implementations Mike Giles (see https://people.maths.ox.ac.uk/~gilesm/mlmc/) provide full MLMC driver example level samplers. Multi-core parallel sampling levels provided built-.","code":""},{"path":"https://mlmc.louisaslett.com/index.html","id":"contact","dir":"","previous_headings":"","what":"Contact","title":"Multi-Level Monte Carlo","text":"Please feel free : submit suggestions bug-reports : https://github.com/louisaslett/mlmc/issues compose e-mail : louis.aslett@durham.ac.uk","code":""},{"path":"https://mlmc.louisaslett.com/index.html","id":"install","dir":"","previous_headings":"","what":"Install","title":"Multi-Level Monte Carlo","text":"can install latest stable release directly CRAN. can install latest release candidate binary r-universe:","code":"install.packages(\"mlmc\") install.packages(\"mlmc\", repos = c(\"https://louisaslett.r-universe.dev\", options(\"repos\")[[1]]))"},{"path":"https://mlmc.louisaslett.com/index.html","id":"install-development-version-not-recommended","dir":"","previous_headings":"","what":"Install development version (not recommended)","title":"Multi-Level Monte Carlo","text":"Installing directly GitHub supported install.packages command. use devtools package install development version desired. releases, tree/commit CRAN releases made recorded, historic source can downloaded .","code":"install.packages(\"devtools\") devtools::install_github(\"louisaslett/mlmc\")"},{"path":"https://mlmc.louisaslett.com/index.html","id":"acknowledgements","dir":"","previous_headings":"","what":"Acknowledgements","title":"Multi-Level Monte Carlo","text":"Louis Aslett supported -like programme grant (EPSRC grant reference number EP/K014463/1 http://www.-like.org.uk) package first conceived. Tigran Nagapetyan Sebastian Vollmer supported EPSRC Grant EP/N000188/1.","code":""},{"path":"https://mlmc.louisaslett.com/index.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Multi-Level Monte Carlo","text":"use software, please cite: Aslett, L. J. M., Giles, M. B., Nagapetyan, T. Vollmer, S. J. (2016), mlmc: Multi-Level Monte Carlo. R package. DOI: 10.32614/CRAN.package.mlmc https://CRAN.R-project.org/package=mlmc Thank-.","code":"@Manual{mlmcpkg, title = {mlmc: Multi-Level Monte Carlo}, author = {Aslett, L. J. M. and Giles, M. B. and Nagapetyan, T. and Vollmer, S. J.}, year = {2016}, note = {R package}, doi = {10.32614/CRAN.package.mlmc}, url = {https://CRAN.R-project.org/package=mlmc} }"},{"path":"https://mlmc.louisaslett.com/reference/mcqmc06_l.html","id":null,"dir":"Reference","previous_headings":"","what":"Financial options using a Milstein discretisation — mcqmc06_l","title":"Financial options using a Milstein discretisation — mcqmc06_l","text":"Financial options based scalar geometric Brownian motion, similar Mike Giles' MCQMC06 paper, Giles (2008), using Milstein discretisation.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mcqmc06_l.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Financial options using a Milstein discretisation — mcqmc06_l","text":"","code":"mcqmc06_l(l, N, option)"},{"path":"https://mlmc.louisaslett.com/reference/mcqmc06_l.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Financial options using a Milstein discretisation — mcqmc06_l","text":"l level simulated. N number samples computed. option option type, 1 5. options : 1 = European call; 2 = Asian call; 3 = lookback call; 4 = digital call; 5 = barrier call.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mcqmc06_l.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Financial options using a Milstein discretisation — mcqmc06_l","text":"named list containing: sums vector length six \\(\\left(\\sum Y_i, \\sum Y_i^2, \\sum Y_i^3, \\sum Y_i^4, \\sum X_i, \\sum X_i^2\\right)\\) \\(Y_i\\) iid simulations expectation \\(E[P_0]\\) \\(l=0\\) expectation \\(E[P_l-P_{l-1}]\\) \\(l>0\\), \\(X_i\\) iid simulations expectation \\(E[P_l]\\). Note first two components used main mlmc() driver, full vector used mlmc.test() convergence tests etc; cost scalar total cost paths simulated, computed \\(N \\times 2^l\\) level \\(l\\).","code":""},{"path":"https://mlmc.louisaslett.com/reference/mcqmc06_l.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Financial options using a Milstein discretisation — mcqmc06_l","text":"function based GPL-2 C++ code Mike Giles.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mcqmc06_l.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Financial options using a Milstein discretisation — mcqmc06_l","text":"Giles, M. (2008) 'Improved Multilevel Monte Carlo Convergence using Milstein Scheme', . Keller, S. Heinrich, H. Niederreiter (eds) Monte Carlo Quasi-Monte Carlo Methods 2006. Berlin, Heidelberg: Springer, pp. 343–358. Available : doi:10.1007/978-3-540-74496-2_20 .","code":""},{"path":"https://mlmc.louisaslett.com/reference/mcqmc06_l.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Financial options using a Milstein discretisation — mcqmc06_l","text":"Louis Aslett Mike Giles ","code":""},{"path":"https://mlmc.louisaslett.com/reference/mcqmc06_l.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Financial options using a Milstein discretisation — mcqmc06_l","text":"","code":"# \\donttest{ # These are similar to the MLMC tests for the MCQMC06 paper # using a Milstein discretisation with 2^l timesteps on level l # # The figures are slightly different due to: # -- change in MSE split # -- change in cost calculation # -- different random number generation # -- switch to S_0=100 # # Note the following takes quite a while to run, for a toy example see after # this block. N0 <- 200 # initial samples on coarse levels Lmin <- 2 # minimum refinement level Lmax <- 10 # maximum refinement level test.res <- list() for(option in 1:5) { if(option == 1) { cat(\"\\n ---- Computing European call ---- \\n\") N <- 20000 # samples for convergence tests L <- 8 # levels for convergence tests Eps <- c(0.005, 0.01, 0.02, 0.05, 0.1) } else if(option == 2) { cat(\"\\n ---- Computing Asian call ---- \\n\") N <- 20000 # samples for convergence tests L <- 8 # levels for convergence tests Eps <- c(0.005, 0.01, 0.02, 0.05, 0.1) } else if(option == 3) { cat(\"\\n ---- Computing lookback call ---- \\n\") N <- 20000 # samples for convergence tests L <- 10 # levels for convergence tests Eps <- c(0.005, 0.01, 0.02, 0.05, 0.1) } else if(option == 4) { cat(\"\\n ---- Computing digital call ---- \\n\") N <- 200000 # samples for convergence tests L <- 8 # levels for convergence tests Eps <- c(0.01, 0.02, 0.05, 0.1, 0.2) } else if(option == 5) { cat(\"\\n ---- Computing barrier call ---- \\n\") N <- 200000 # samples for convergence tests L <- 8 # levels for convergence tests Eps <- c(0.005, 0.01, 0.02, 0.05, 0.1) } test.res[[option]] <- mlmc.test(mcqmc06_l, N, L, N0, Eps, Lmin, Lmax, option = option) # print exact analytic value, based on S0=K T <- 1 r <- 0.05 sig <- 0.2 K <- 100 B <- 0.85*K k <- 0.5*sig^2/r; d1 <- (r+0.5*sig^2)*T / (sig*sqrt(T)) d2 <- (r-0.5*sig^2)*T / (sig*sqrt(T)) d3 <- (2*log(B/K) + (r+0.5*sig^2)*T) / (sig*sqrt(T)) d4 <- (2*log(B/K) + (r-0.5*sig^2)*T) / (sig*sqrt(T)) if(option == 1) { val <- K*( pnorm(d1) - exp(-r*T)*pnorm(d2) ) } else if(option == 2) { val <- NA } else if(option == 3) { val <- K*( pnorm(d1) - pnorm(-d1)*k - exp(-r*T)*(pnorm(d2) - pnorm(d2)*k) ) } else if(option == 4) { val <- K*exp(-r*T)*pnorm(d2) } else if(option == 5) { val <- K*( pnorm(d1) - exp(-r*T)*pnorm(d2) - ((K/B)^(1-1/k))*((B^2)/(K^2)*pnorm(d3) - exp(-r*T)*pnorm(d4)) ) } if(is.na(val)) { cat(sprintf(\"\\n Exact value unknown, MLMC value: %f \\n\", test.res[[option]]$P[1])) } else { cat(sprintf(\"\\n Exact value: %f, MLMC value: %f \\n\", val, test.res[[option]]$P[1])) } # plot results plot(test.res[[option]]) } #> #> ---- Computing European call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 20000 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0030e+01 1.0030e+01 1.9725e+02 1.9725e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 1.8716e-01 1.0359e+01 1.6531e-01 2.0988e+02 9.8531e+01 2.3102e-01 2.0000e+00 #> 2 1.0142e-01 1.0191e+01 4.1839e-02 2.0683e+02 2.8282e+01 4.3754e-01 4.0000e+00 #> 3 5.5153e-02 1.0558e+01 1.2325e-02 2.1670e+02 2.1426e+01 5.0386e-01 8.0000e+00 #> 4 2.7904e-02 1.0468e+01 3.2321e-03 2.1466e+02 1.7647e+01 1.8893e-01 1.6000e+01 #> 5 1.3913e-02 1.0420e+01 8.2640e-04 2.1465e+02 1.2310e+01 9.9685e-02 3.2000e+01 #> 6 7.2131e-03 1.0479e+01 2.1421e-04 2.1745e+02 1.1577e+01 8.2241e-02 6.4000e+01 #> 7 3.5650e-03 1.0475e+01 5.2975e-05 2.1736e+02 1.0232e+01 1.0760e-02 1.2800e+02 #> 8 1.7857e-03 1.0545e+01 1.3436e-05 2.1571e+02 1.0093e+01 1.0816e-01 2.5600e+02 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.963583 (exponent for MLMC weak convergence) #> beta = 1.937392 (exponent for MLMC variance) #> gamma = 1.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0458e+01 1.361e+07 2.945e+09 216.36 11917020 231958 98151 33333 12301 4375 1552 615 223 #> 0.0100 1.0439e+01 3.356e+06 3.710e+08 110.52 2953179 65020 21963 7800 2913 1068 386 136 #> 0.0200 1.0470e+01 8.371e+05 4.639e+07 55.41 740921 14276 5398 2185 776 293 106 #> 0.0500 1.0461e+01 1.312e+05 3.663e+06 27.93 117176 2060 829 365 132 48 #> 0.1000 1.0304e+01 3.137e+04 4.579e+05 14.60 28620 543 200 64 22 #> #> #> Exact value: 10.450584, MLMC value: 10.458105 #> #> ---- Computing Asian call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 20000 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 5.6185e+00 5.6185e+00 6.0313e+01 6.0313e+01 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 4.1755e-02 5.6931e+00 2.6371e-01 6.2423e+01 2.3578e+01 9.5912e-02 2.0000e+00 #> 2 3.9962e-02 5.7058e+00 3.7704e-02 6.1951e+01 1.2360e+01 8.0573e-02 4.0000e+00 #> 3 2.7370e-02 5.7290e+00 6.0579e-03 6.2682e+01 8.1099e+00 1.2570e-02 8.0000e+00 #> 4 1.5138e-02 5.7909e+00 1.2289e-03 6.4331e+01 7.6054e+00 1.3822e-01 1.6000e+01 #> 5 7.5845e-03 5.7123e+00 2.6881e-04 6.3121e+01 7.4456e+00 2.5437e-01 3.2000e+01 #> 6 3.8863e-03 5.6738e+00 6.2498e-05 6.1495e+01 7.9930e+00 1.2635e-01 6.4000e+01 #> 7 1.9756e-03 5.7571e+00 1.5521e-05 6.2941e+01 7.8415e+00 2.4282e-01 1.2800e+02 #> 8 1.0065e-03 5.8278e+00 3.8637e-06 6.4531e+01 7.4338e+00 2.0594e-01 2.5600e+02 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.818556 (exponent for MLMC weak convergence) #> beta = 2.269413 (exponent for MLMC variance) #> gamma = 1.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 5.7609e+00 4.738e+06 8.811e+08 185.94 3878099 176768 48852 15162 4375 1512 497 178 67 #> 0.0100 5.7537e+00 1.407e+06 1.074e+08 76.37 1189144 44761 13058 3745 1110 392 142 50 #> 0.0200 5.7585e+00 2.909e+05 1.312e+07 45.09 239760 10909 2985 928 289 104 32 #> 0.0500 5.7167e+00 4.541e+04 1.077e+06 23.72 37708 1729 451 149 48 15 #> 0.1000 5.6693e+00 1.250e+04 1.372e+05 10.98 10250 429 200 38 18 #> #> #> Exact value unknown, MLMC value: 5.760949 #> #> ---- Computing lookback call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 20000 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.7603e+01 1.7603e+01 1.8757e+02 1.8757e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 -1.1974e-01 1.7458e+01 1.4071e+00 1.9666e+02 9.2816e+00 4.0921e-02 2.0000e+00 #> 2 -1.3427e-01 1.7475e+01 5.0942e-01 2.0891e+02 9.1129e+00 2.4391e-01 4.0000e+00 #> 3 -8.8887e-02 1.7226e+01 1.4282e-01 2.0632e+02 9.4423e+00 2.5918e-01 8.0000e+00 #> 4 -5.4996e-02 1.7188e+01 4.0886e-02 2.1052e+02 8.3295e+00 2.7305e-02 1.6000e+01 #> 5 -2.6679e-02 1.7198e+01 1.0245e-02 2.1394e+02 8.6646e+00 5.9360e-02 3.2000e+01 #> 6 -1.4201e-02 1.7086e+01 2.6724e-03 2.0766e+02 8.6317e+00 1.5823e-01 6.4000e+01 #> 7 -7.2594e-03 1.7233e+01 6.7415e-04 2.1055e+02 7.3269e+00 2.5092e-01 1.2800e+02 #> 8 -3.5000e-03 1.7275e+01 1.6549e-04 2.1712e+02 7.9473e+00 7.3983e-02 2.5600e+02 #> 9 -1.7809e-03 1.7173e+01 4.1676e-05 2.1442e+02 7.3364e+00 1.6080e-01 5.1200e+02 #> 10 -8.6176e-04 1.7440e+01 1.0424e-05 2.1902e+02 8.6798e+00 4.2827e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.852889 (exponent for MLMC weak convergence) #> beta = 1.920578 (exponent for MLMC variance) #> gamma = 1.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.7220e+01 2.197e+07 1.196e+10 544.53 14695671 908426 378089 146440 54138 19500 6933 2469 917 332 113 #> 0.0100 1.7227e+01 5.350e+06 7.411e+08 138.53 3626992 222962 92265 36156 13314 4941 1741 615 223 #> 0.0200 1.7201e+01 1.334e+06 1.853e+08 138.92 902716 55846 23242 9121 3370 1208 430 150 55 #> 0.0500 1.7265e+01 2.030e+05 7.088e+06 34.92 141854 8734 3548 1379 508 186 68 #> 0.1000 1.7118e+01 5.179e+04 1.772e+06 34.21 35378 2295 934 393 137 50 18 #> #> #> Exact value: 17.216802, MLMC value: 17.220350 #> #> ---- Computing digital call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 2e+05 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 5.6951e+01 5.6951e+01 1.0000e-10 1.0000e-10 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 -2.7021e+00 5.4263e+01 2.0431e-01 7.2354e+02 1.1150e+01 7.9904e-02 2.0000e+00 #> 2 -7.1604e-01 5.3580e+01 1.9385e+00 1.1897e+03 1.9612e+01 7.8338e-02 4.0000e+00 #> 3 -2.0194e-01 5.3346e+01 1.2403e+00 1.5085e+03 2.2141e+01 6.4013e-02 8.0000e+00 #> 4 -5.9328e-02 5.3352e+01 5.4685e-01 1.7222e+03 2.7503e+01 1.2010e-01 1.6000e+01 #> 5 -2.2149e-02 5.3216e+01 2.1220e-01 1.8724e+03 4.3452e+01 1.9886e-01 3.2000e+01 #> 6 -7.9524e-03 5.3246e+01 7.8848e-02 1.9789e+03 5.6893e+01 6.2962e-02 6.4000e+01 #> 7 -3.6181e-03 5.3389e+01 2.7991e-02 2.0497e+03 8.0117e+01 2.4439e-01 1.2800e+02 #> 8 -1.2441e-03 5.3354e+01 1.0449e-02 2.1024e+03 1.1769e+02 5.5995e-02 2.5600e+02 #> #> WARNING: kurtosis on finest level = 117.692596 #> indicates MLMC correction dominated by a few rare paths; #> for information on the connection to variance of sample variances, #> see http://mathworld.wolfram.com/SampleVarianceDistribution.html #> #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 1.561395 (exponent for MLMC weak convergence) #> beta = 0.879603 (exponent for MLMC variance) #> gamma = 1.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0100 5.3242e+01 3.755e+06 3.498e+09 931.64 200 71109 155815 88148 41078 17950 8299 4072 #> 0.0200 5.3237e+01 7.650e+05 4.222e+08 551.88 200 16210 34921 20467 9378 4267 2224 #> 0.0500 5.3256e+01 1.001e+05 3.195e+07 319.11 200 2404 4796 2991 1591 830 #> 0.1000 5.3214e+01 1.210e+04 3.674e+06 303.70 200 381 842 475 248 #> 0.2000 5.3294e+01 4.020e+03 9.185e+05 228.49 200 200 283 140 73 #> #> #> Exact value: 53.232482, MLMC value: 53.241652 #> #> ---- Computing barrier call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 2e+05 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 9.4564e+00 9.4564e+00 1.8871e+02 1.8871e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 1.6056e-01 9.6193e+00 1.7069e-01 1.9914e+02 6.1603e+01 1.2323e-02 2.0000e+00 #> 2 1.4474e-01 9.6700e+00 1.5745e-01 2.0464e+02 1.0612e+02 4.8690e-01 4.0000e+00 #> 3 9.8315e-02 9.8418e+00 1.4427e-01 2.1162e+02 3.9947e+02 3.7507e-01 8.0000e+00 #> 4 4.6888e-02 9.9143e+00 5.1685e-02 2.1567e+02 1.5447e+03 1.2963e-01 1.6000e+01 #> 5 2.0359e-02 9.9093e+00 1.0326e-02 2.1578e+02 1.2857e+03 1.2834e-01 3.2000e+01 #> 6 1.0032e-02 9.9355e+00 4.2701e-03 2.1714e+02 3.9267e+03 8.1491e-02 6.4000e+01 #> 7 4.8781e-03 9.9329e+00 1.1130e-03 2.1622e+02 1.7346e+03 3.7701e-02 1.2800e+02 #> 8 2.3827e-03 9.9133e+00 4.1529e-04 2.1690e+02 6.9372e+03 1.1119e-01 2.5600e+02 #> #> WARNING: kurtosis on finest level = 6937.174649 #> indicates MLMC correction dominated by a few rare paths; #> for information on the connection to variance of sample variances, #> see http://mathworld.wolfram.com/SampleVarianceDistribution.html #> #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.929256 (exponent for MLMC weak convergence) #> beta = 1.357869 (exponent for MLMC variance) #> gamma = 1.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 9.9433e+00 2.155e+07 5.923e+09 274.79 14584932 310729 219105 148864 56194 21897 10346 7173 2550 873 #> 0.0100 9.9355e+00 4.662e+06 7.403e+08 158.79 3394165 72037 49865 32362 13511 5756 2045 645 203 #> 0.0200 9.9761e+00 1.264e+06 9.225e+07 72.96 883634 18369 12864 8275 3246 2341 951 302 #> 0.0500 9.8703e+00 1.638e+05 7.412e+06 45.25 127079 2734 2077 943 407 169 54 #> 0.1000 9.7337e+00 3.815e+04 9.207e+05 24.13 30393 711 400 260 98 34 #> #> #> Exact value: 9.949270, MLMC value: 9.943268 # } # The level sampler can be called directly to retrieve the relevant level sums: mcqmc06_l(l = 7, N = 10, option = 1) #> $sums #> [1] 2.648764e-02 2.889784e-04 3.607043e-06 5.105926e-08 1.032765e+02 #> [6] 2.338980e+03 #> #> $cost #> [1] 1280 #>"},{"path":"https://mlmc.louisaslett.com/reference/mlmc.html","id":null,"dir":"Reference","previous_headings":"","what":"Multi-level Monte Carlo estimation — mlmc","title":"Multi-level Monte Carlo estimation — mlmc","text":"function Multi-level Monte Carlo driver sample levels user specified function.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Multi-level Monte Carlo estimation — mlmc","text":"","code":"mlmc( Lmin, Lmax, N0, eps, mlmc_l, alpha = NA, beta = NA, gamma = NA, parallel = NA, ... )"},{"path":"https://mlmc.louisaslett.com/reference/mlmc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Multi-level Monte Carlo estimation — mlmc","text":"Lmin minimum level refinement. Must \\(\\ge 2\\). Lmax maximum level refinement. Must \\(\\ge\\) Lmin. N0 initial number samples used first 3 levels subsequent levels automatically added. Must \\(> 0\\). eps target accuracy estimate (root mean square error). Must \\(> 0\\). mlmc_l user supplied function provides estimate level \\(l\\). must take least two arguments, first level number simulated second number paths. Additional arguments can taken desired: additional ... arguments function forwarded user defined mlmc_l function. user supplied function return named list containing one element named sums second named cost, : sums vector length least two. first two elements \\(\\left(\\sum Y_i, \\sum Y_i^2\\right)\\) \\(Y_i\\) iid simulations expectation \\(E[P_0]\\) \\(l=0\\) expectation \\(E[P_l-P_{l-1}]\\) \\(l>0\\). Note typically user supplied level sampler actually return vector length six, also enabling use mlmc.test() function perform convergence tests, kurtosis, telescoping sum checks. See mlmc.test() definition remaining four elements. cost scalar total cost paths simulated. example, financial options samplers included package, calculated \\(NM^l\\), \\(N\\) number paths requested call user function mlmc_l, \\(M\\) refinement cost factor (\\(M=2\\) mcqmc06_l() \\(M=4\\) opre_l()), \\(l\\) level sampled. See function (source code ) opre_l() mcqmc06_l() package example user supplied level samplers. alpha weak error, \\(O(2^{-\\alpha l})\\). Must \\(> 0\\) specified. NA alpha estimated. beta variance, \\(O(2^{-\\beta l})\\). Must \\(> 0\\) specified. NA beta estimated. gamma sample cost, \\(O(2^{\\gamma l})\\). Must \\(> 0\\) specified. NA gamma estimated. parallel integer supplied, R fork parallel parallel processes compute level estimate parallel. ... additional arguments passed user supplied mlmc_l function called.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Multi-level Monte Carlo estimation — mlmc","text":"named list containing: P MLMC estimate; Nl vector number samples performed level; Cl Per sample cost level.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Multi-level Monte Carlo estimation — mlmc","text":"Multilevel Monte Carlo Method method originated works Giles (2008) Heinrich (1998). Consider sequence \\(P_0, P_1, \\ldots\\), approximates \\(P_L\\) increasing accuracy, also increasing cost, simple identity $$E[P_L] = E[P_0] + \\sum_{l=1}^L E[P_l-P_{l-1}],$$ therefore can use following unbiased estimator \\(E[P_L]\\), $$N_0^{-1} \\sum_{n=1}^{N_0} P_0^{(0,n)} + \\sum_{l=1}^L \\left\\{ N_l^{-1} \\sum_{n=1}^{N_l} \\left(P_l^{(l,n)} - P_{l-1}^{(l,n)}\\right) \\right\\}$$ \\(N_l\\) samples produced level \\(l\\). inclusion level \\(l\\) superscript \\((l,n)\\) indicates samples used level correction independent. Set \\(C_0\\), \\(V_0\\) cost variance one sample \\(P_0\\), \\(C_l, V_l\\) cost variance one sample \\(P_l - P_{l-1}\\), overall cost variance multilevel estimator \\(\\sum_{l=0}^L N_l C_l\\) \\(\\sum_{l=0}^L N_l^{-1} V_l\\), respectively. idea behind method, provided product \\(V_l C_l\\) decreases \\(l\\), .e. cost increases level slower variance decreases, one can achieve significant computational savings, can formalised Theorem 1 Giles (2015). information multilevel Monte Carlo methods, see webpage https://people.maths.ox.ac.uk/gilesm/mlmc_community.html lists research groups working area, main publications. function based GPL-2 'Matlab' code Mike Giles.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Multi-level Monte Carlo estimation — mlmc","text":"Giles, M.B. (2008) 'Multilevel Monte Carlo Path Simulation', Operations Research, 56(3), pp. 607–617. Available : doi:10.1287/opre.1070.0496 . Giles, M.B. (2015) 'Multilevel Monte Carlo methods', Acta Numerica, 24, pp. 259–328. Available : doi:10.1017/S096249291500001X . Heinrich, S. (1998) 'Monte Carlo Complexity Global Solution Integral Equations', Journal Complexity, 14(2), pp. 151–175. Available : doi:10.1006/jcom.1998.0471 .","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Multi-level Monte Carlo estimation — mlmc","text":"Louis Aslett Mike Giles Tigran Nagapetyan ","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Multi-level Monte Carlo estimation — mlmc","text":"","code":"mlmc(2, 6, 1000, 0.01, opre_l, option = 1) #> $P #> [1] 10.44313 #> #> $Nl #> [1] 4257656 353933 99613 21890 #> #> $Cl #> [1] 1 4 16 64 #> mlmc(2, 10, 1000, 0.01, mcqmc06_l, option = 1) #> $P #> [1] 10.45051 #> #> $Nl #> [1] 2966234 58326 24428 8277 3060 1127 390 154 #> #> $Cl #> [1] 1 2 4 8 16 32 64 128 #>"},{"path":"https://mlmc.louisaslett.com/reference/mlmc.test.html","id":null,"dir":"Reference","previous_headings":"","what":"Multi-level Monte Carlo estimation test suite — mlmc.test","title":"Multi-level Monte Carlo estimation test suite — mlmc.test","text":"Computes suite diagnostic values MLMC estimation problem.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.test.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Multi-level Monte Carlo estimation test suite — mlmc.test","text":"","code":"mlmc.test( mlmc_l, N, L, N0, eps.v, Lmin, Lmax, alpha = NA, beta = NA, gamma = NA, parallel = NA, silent = FALSE, ... )"},{"path":"https://mlmc.louisaslett.com/reference/mlmc.test.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Multi-level Monte Carlo estimation test suite — mlmc.test","text":"mlmc_l user supplied function provides estimate level \\(l\\). must take least two arguments, first level number simulated second number paths. Additional arguments can taken desired: additional ... arguments function forwarded user defined mlmc_l function. user supplied function return named list containing one element named sums second named cost, : sums vector length six \\(\\left(\\sum Y_i, \\sum Y_i^2, \\sum Y_i^3, \\sum Y_i^4, \\sum X_i, \\sum X_i^2\\right)\\) \\(Y_i\\) iid simulations expectation \\(E[P_0]\\) \\(l=0\\) expectation \\(E[P_l-P_{l-1}]\\) \\(l>0\\), \\(X_i\\) iid simulations expectation \\(E[P_l]\\). Note differs main mlmc() driver, requires first two elements order calculate estimate. remaining elements required mlmc.test() since used convergence tests, kurtosis, telescoping sum checks. cost scalar total cost paths simulated. example, financial options samplers included package, calculated \\(NM^l\\), \\(N\\) number paths requested call user function mlmc_l, \\(M\\) refinement cost factor (\\(M=2\\) mcqmc06_l() \\(M=4\\) opre_l()), \\(l\\) level sampled. See function (source code ) opre_l() mcqmc06_l() package example user supplied level samplers. N number samples use convergence tests, kurtosis, telescoping sum check. L number levels use convergence tests, kurtosis, telescoping sum check. N0 initial number samples used first 3 levels subsequent levels automatically added complexity tests. Must \\(> 0\\). eps.v vector one target accuracies complexity tests. Must \\(> 0\\). Lmin minimum level refinement complexity tests. Must \\(\\ge 2\\). Lmax maximum level refinement complexity tests. Must \\(\\ge\\) Lmin. alpha weak error, \\(O(2^{-\\alpha l})\\). Must \\(> 0\\) specified. NA alpha estimated. beta variance, \\(O(2^{-\\beta l})\\). Must \\(> 0\\) specified. NA beta estimated. gamma sample cost, \\(O(2^{\\gamma l})\\). Must \\(> 0\\) specified. NA gamma estimated. parallel integer supplied, R fork parallel parallel processes. done convergence tests section splitting N samples evenly possible across cores sampling level. also done MLMC complexity tests passing parallel argument mlmc() driver targeting accuracy level eps. silent set TRUE supress running output (identical output can still printed printing return result) ... additional arguments passed user supplied mlmc_l function called","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.test.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Multi-level Monte Carlo estimation test suite — mlmc.test","text":"mlmc.test object contains computed diagnostic values. object can printed plotted (see plot.mlmc.test).","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.test.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Multi-level Monte Carlo estimation test suite — mlmc.test","text":"See one example level sampler functions (e.g. opre_l()) example usage. function based GPL-2 'Matlab' code Mike Giles.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.test.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Multi-level Monte Carlo estimation test suite — mlmc.test","text":"Louis Aslett Mike Giles Tigran Nagapetyan ","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.test.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Multi-level Monte Carlo estimation test suite — mlmc.test","text":"","code":"# \\donttest{ # Example calls with realistic arguments # Financial options using an Euler-Maruyama discretisation tst <- mlmc.test(opre_l, N = 2000000, L = 5, N0 = 1000, eps.v = c(0.005, 0.01, 0.02, 0.05, 0.1), Lmin = 2, Lmax = 6, option = 1) #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 2e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0209e+01 1.0209e+01 1.6139e+02 1.6139e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.0971e-01 1.0420e+01 4.4439e+00 2.0102e+02 2.0055e+01 2.9916e-02 4.0000e+00 #> 2 2.9164e-02 1.0443e+01 1.0641e+00 2.1243e+02 1.2387e+01 9.3236e-02 1.6000e+01 #> 3 5.8030e-03 1.0457e+01 2.7256e-01 2.1538e+02 7.5182e+00 1.1818e-01 6.4000e+01 #> 4 1.6226e-03 1.0450e+01 6.8529e-02 2.1643e+02 6.2241e+00 1.3021e-01 2.5600e+02 #> 5 5.6870e-04 1.0456e+01 1.7268e-02 2.1633e+02 5.9348e+00 8.0291e-02 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.122090 (exponent for MLMC weak convergence) #> beta = 1.997195 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0449e+01 4.625e+07 2.955e+09 63.88 19941583 1650853 405719 103214 25829 #> 0.0100 1.0454e+01 8.433e+06 1.838e+08 21.80 4257398 354804 85692 21643 #> 0.0200 1.0449e+01 2.127e+06 4.595e+07 21.60 1068793 88086 22057 5520 #> 0.0500 1.0440e+01 2.519e+05 1.813e+06 7.20 159399 11284 2959 #> 0.1000 1.0495e+01 6.324e+04 4.532e+05 7.17 35177 3016 1000 #> tst #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 2e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0209e+01 1.0209e+01 1.6139e+02 1.6139e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.0971e-01 1.0420e+01 4.4439e+00 2.0102e+02 2.0055e+01 2.9916e-02 4.0000e+00 #> 2 2.9164e-02 1.0443e+01 1.0641e+00 2.1243e+02 1.2387e+01 9.3236e-02 1.6000e+01 #> 3 5.8030e-03 1.0457e+01 2.7256e-01 2.1538e+02 7.5182e+00 1.1818e-01 6.4000e+01 #> 4 1.6226e-03 1.0450e+01 6.8529e-02 2.1643e+02 6.2241e+00 1.3021e-01 2.5600e+02 #> 5 5.6870e-04 1.0456e+01 1.7268e-02 2.1633e+02 5.9348e+00 8.0291e-02 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.122090 (exponent for MLMC weak convergence) #> beta = 1.997195 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0449e+01 4.625e+07 2.955e+09 63.88 19941583 1650853 405719 103214 25829 #> 0.0100 1.0454e+01 8.433e+06 1.838e+08 21.80 4257398 354804 85692 21643 #> 0.0200 1.0449e+01 2.127e+06 4.595e+07 21.60 1068793 88086 22057 5520 #> 0.0500 1.0440e+01 2.519e+05 1.813e+06 7.20 159399 11284 2959 #> 0.1000 1.0495e+01 6.324e+04 4.532e+05 7.17 35177 3016 1000 #> plot(tst) # Financial options using a Milstein discretisation tst <- mlmc.test(mcqmc06_l, N = 20000, L = 8, N0 = 200, eps.v = c(0.005, 0.01, 0.02, 0.05, 0.1), Lmin = 2, Lmax = 10, option = 1) #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 20000 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0133e+01 1.0133e+01 1.9810e+02 1.9810e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 1.8339e-01 1.0238e+01 1.4650e-01 2.0666e+02 4.3668e+01 1.2791e-01 2.0000e+00 #> 2 1.0178e-01 1.0207e+01 4.1696e-02 2.0649e+02 3.1277e+01 2.1643e-01 4.0000e+00 #> 3 5.4679e-02 1.0390e+01 1.2096e-02 2.1192e+02 2.2094e+01 2.0862e-01 8.0000e+00 #> 4 2.7491e-02 1.0312e+01 3.0769e-03 2.1030e+02 1.2999e+01 1.7120e-01 1.6000e+01 #> 5 1.3946e-02 1.0439e+01 8.5509e-04 2.2017e+02 1.3315e+01 1.8132e-01 3.2000e+01 #> 6 6.9500e-03 1.0260e+01 2.1296e-04 2.1398e+02 1.1626e+01 2.9709e-01 6.4000e+01 #> 7 3.5764e-03 1.0542e+01 5.3863e-05 2.1728e+02 9.9385e+00 4.4704e-01 1.2800e+02 #> 8 1.8070e-03 1.0587e+01 1.3390e-05 2.1707e+02 9.4222e+00 6.9319e-02 2.5600e+02 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.960913 (exponent for MLMC weak convergence) #> beta = 1.919459 (exponent for MLMC variance) #> gamma = 1.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0447e+01 1.355e+07 2.964e+09 218.65 11903219 229699 88580 33052 12456 4446 1600 569 220 #> 0.0100 1.0438e+01 3.363e+06 3.708e+08 110.27 2957414 56143 25072 8068 2875 1106 426 155 #> 0.0200 1.0468e+01 9.014e+05 4.565e+07 50.64 795790 15288 8075 2046 735 266 96 #> 0.0500 1.0432e+01 1.313e+05 3.758e+06 28.62 116815 2610 840 297 127 46 #> 0.1000 1.0251e+01 3.492e+04 4.486e+05 12.85 31940 613 200 65 27 #> tst #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 20000 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0133e+01 1.0133e+01 1.9810e+02 1.9810e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 1.8339e-01 1.0238e+01 1.4650e-01 2.0666e+02 4.3668e+01 1.2791e-01 2.0000e+00 #> 2 1.0178e-01 1.0207e+01 4.1696e-02 2.0649e+02 3.1277e+01 2.1643e-01 4.0000e+00 #> 3 5.4679e-02 1.0390e+01 1.2096e-02 2.1192e+02 2.2094e+01 2.0862e-01 8.0000e+00 #> 4 2.7491e-02 1.0312e+01 3.0769e-03 2.1030e+02 1.2999e+01 1.7120e-01 1.6000e+01 #> 5 1.3946e-02 1.0439e+01 8.5509e-04 2.2017e+02 1.3315e+01 1.8132e-01 3.2000e+01 #> 6 6.9500e-03 1.0260e+01 2.1296e-04 2.1398e+02 1.1626e+01 2.9709e-01 6.4000e+01 #> 7 3.5764e-03 1.0542e+01 5.3863e-05 2.1728e+02 9.9385e+00 4.4704e-01 1.2800e+02 #> 8 1.8070e-03 1.0587e+01 1.3390e-05 2.1707e+02 9.4222e+00 6.9319e-02 2.5600e+02 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.960913 (exponent for MLMC weak convergence) #> beta = 1.919459 (exponent for MLMC variance) #> gamma = 1.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0447e+01 1.355e+07 2.964e+09 218.65 11903219 229699 88580 33052 12456 4446 1600 569 220 #> 0.0100 1.0438e+01 3.363e+06 3.708e+08 110.27 2957414 56143 25072 8068 2875 1106 426 155 #> 0.0200 1.0468e+01 9.014e+05 4.565e+07 50.64 795790 15288 8075 2046 735 266 96 #> 0.0500 1.0432e+01 1.313e+05 3.758e+06 28.62 116815 2610 840 297 127 46 #> 0.1000 1.0251e+01 3.492e+04 4.486e+05 12.85 31940 613 200 65 27 #> plot(tst) # } # Toy versions for CRAN tests tst <- mlmc.test(opre_l, N = 10000, L = 5, N0 = 1000, eps.v = c(0.025, 0.1), Lmin = 2, Lmax = 6, option = 1) #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 10000 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0144e+01 1.0144e+01 1.5933e+02 1.5933e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.0461e-01 1.0494e+01 4.3545e+00 2.0017e+02 1.6552e+01 1.6836e-01 4.0000e+00 #> 2 3.4172e-02 1.0188e+01 1.0920e+00 2.0313e+02 1.3486e+01 3.8611e-01 1.6000e+01 #> 3 2.7394e-03 1.0609e+01 2.7241e-01 2.1473e+02 8.9020e+00 4.7445e-01 6.4000e+01 #> 4 4.6225e-03 1.0487e+01 7.0387e-02 2.2204e+02 6.2642e+00 1.4175e-01 2.5600e+02 #> 5 2.3568e-03 1.0375e+01 1.6529e-02 2.1034e+02 5.6902e+00 1.2895e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 1.576591 (exponent for MLMC weak convergence) #> beta = 2.003820 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0250 1.0442e+01 1.352e+06 2.932e+07 21.68 682155 56440 13888 3468 #> 0.1000 1.0326e+01 6.651e+04 4.333e+05 6.52 38193 3079 1000 #> tst <- mlmc.test(mcqmc06_l, N = 10000, L = 8, N0 = 1000, eps.v = c(0.025, 0.1), Lmin = 2, Lmax = 10, option = 1) #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 10000 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 9.7083e+00 9.7083e+00 1.8872e+02 1.8872e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 1.8889e-01 1.0493e+01 1.5689e-01 2.1033e+02 4.2469e+01 6.9418e-01 2.0000e+00 #> 2 1.0293e-01 1.0345e+01 4.1077e-02 2.1021e+02 2.5473e+01 2.8726e-01 4.0000e+00 #> 3 5.2791e-02 1.0138e+01 1.1696e-02 2.1027e+02 2.0845e+01 2.9683e-01 8.0000e+00 #> 4 2.7545e-02 1.0462e+01 3.1582e-03 2.1956e+02 1.3111e+01 3.3625e-01 1.6000e+01 #> 5 1.4108e-02 1.0503e+01 7.9526e-04 2.1093e+02 1.2555e+01 2.9865e-02 3.2000e+01 #> 6 6.8579e-03 1.0170e+01 2.0129e-04 2.1102e+02 9.9169e+00 3.8931e-01 6.4000e+01 #> 7 3.5937e-03 1.0490e+01 5.4733e-05 2.1709e+02 1.2669e+01 3.6073e-01 1.2800e+02 #> 8 1.7843e-03 1.0185e+01 1.3757e-05 2.1383e+02 9.7348e+00 3.4885e-01 2.5600e+02 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.965258 (exponent for MLMC weak convergence) #> beta = 1.924650 (exponent for MLMC variance) #> gamma = 1.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0250 1.0446e+01 5.278e+05 2.881e+07 54.59 468086 9101 3436 1207 505 183 65 #> 0.1000 1.0334e+01 3.549e+04 4.684e+05 13.20 28562 1000 1000 76 20 #>"},{"path":"https://mlmc.louisaslett.com/reference/opre_l.html","id":null,"dir":"Reference","previous_headings":"","what":"Financial options using an Euler-Maruyama discretisation — opre_l","title":"Financial options using an Euler-Maruyama discretisation — opre_l","text":"Financial options based scalar geometric Brownian motion Heston models, similar Mike Giles' original 2008 Operations Research paper, Giles (2008), using Euler-Maruyama discretisation","code":""},{"path":"https://mlmc.louisaslett.com/reference/opre_l.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Financial options using an Euler-Maruyama discretisation — opre_l","text":"","code":"opre_l(l, N, option)"},{"path":"https://mlmc.louisaslett.com/reference/opre_l.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Financial options using an Euler-Maruyama discretisation — opre_l","text":"l level simulated. N number samples computed. option option type, 1 5. options : 1 = European call; 2 = Asian call; 3 = lookback call; 4 = digital call; 5 = Heston model.","code":""},{"path":"https://mlmc.louisaslett.com/reference/opre_l.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Financial options using an Euler-Maruyama discretisation — opre_l","text":"named list containing: sums vector length six \\(\\left(\\sum Y_i, \\sum Y_i^2, \\sum Y_i^3, \\sum Y_i^4, \\sum X_i, \\sum X_i^2\\right)\\) \\(Y_i\\) iid simulations expectation \\(E[P_0]\\) \\(l=0\\) expectation \\(E[P_l-P_{l-1}]\\) \\(l>0\\), \\(X_i\\) iid simulations expectation \\(E[P_l]\\). Note first two components used main mlmc() driver, full vector used mlmc.test() convergence tests etc; cost scalar total cost paths simulated, computed \\(N \\times 4^l\\) level \\(l\\).","code":""},{"path":"https://mlmc.louisaslett.com/reference/opre_l.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Financial options using an Euler-Maruyama discretisation — opre_l","text":"function based GPL-2 'Matlab' code Mike Giles.","code":""},{"path":"https://mlmc.louisaslett.com/reference/opre_l.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Financial options using an Euler-Maruyama discretisation — opre_l","text":"Giles, M.B. (2008) 'Multilevel Monte Carlo Path Simulation', Operations Research, 56(3), pp. 607–617. Available : doi:10.1287/opre.1070.0496 .","code":""},{"path":"https://mlmc.louisaslett.com/reference/opre_l.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Financial options using an Euler-Maruyama discretisation — opre_l","text":"Louis Aslett Mike Giles Tigran Nagapetyan ","code":""},{"path":"https://mlmc.louisaslett.com/reference/opre_l.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Financial options using an Euler-Maruyama discretisation — opre_l","text":"","code":"# \\donttest{ # These are similar to the MLMC tests for the original # 2008 Operations Research paper, using an Euler-Maruyama # discretisation with 4^l timesteps on level l. # # The differences are: # -- the plots do not have the extrapolation results # -- two plots are log_2 rather than log_4 # -- the new MLMC driver is a little different # -- switch to X_0=100 instead of X_0=1 # # Note the following takes quite a while to run, for a toy example see after # this block. N0 <- 1000 # initial samples on coarse levels Lmin <- 2 # minimum refinement level Lmax <- 6 # maximum refinement level test.res <- list() for(option in 1:5) { if(option == 1) { cat(\"\\n ---- Computing European call ---- \\n\") N <- 1000000 # samples for convergence tests L <- 5 # levels for convergence tests Eps <- c(0.005, 0.01, 0.02, 0.05, 0.1) } else if(option == 2) { cat(\"\\n ---- Computing Asian call ---- \\n\") N <- 1000000 # samples for convergence tests L <- 5 # levels for convergence tests Eps <- c(0.005, 0.01, 0.02, 0.05, 0.1) } else if(option == 3) { cat(\"\\n ---- Computing lookback call ---- \\n\") N <- 1000000 # samples for convergence tests L <- 5 # levels for convergence tests Eps <- c(0.01, 0.02, 0.05, 0.1, 0.2) } else if(option == 4) { cat(\"\\n ---- Computing digital call ---- \\n\") N <- 4000000 # samples for convergence tests L <- 5 # levels for convergence tests Eps <- c(0.02, 0.05, 0.1, 0.2, 0.5) } else if(option == 5) { cat(\"\\n ---- Computing Heston model ---- \\n\") N <- 2000000 # samples for convergence tests L <- 5 # levels for convergence tests Eps <- c(0.005, 0.01, 0.02, 0.05, 0.1) } test.res[[option]] <- mlmc.test(opre_l, N, L, N0, Eps, Lmin, Lmax, option = option) # print exact analytic value, based on S0=K T <- 1 r <- 0.05 sig <- 0.2 K <- 100 k <- 0.5*sig^2/r; d1 <- (r+0.5*sig^2)*T / (sig*sqrt(T)) d2 <- (r-0.5*sig^2)*T / (sig*sqrt(T)) if(option == 1) { val <- K*( pnorm(d1) - exp(-r*T)*pnorm(d2) ) } else if(option == 2) { val <- NA } else if(option == 3) { val <- K*( pnorm(d1) - pnorm(-d1)*k - exp(-r*T)*(pnorm(d2) - pnorm(d2)*k) ) } else if(option == 4) { val <- K*exp(-r*T)*pnorm(d2) } else if(option == 5) { val <- NA } if(is.na(val)) { cat(sprintf(\"\\n Exact value unknown, MLMC value: %f \\n\", test.res[[option]]$P[1])) } else { cat(sprintf(\"\\n Exact value: %f, MLMC value: %f \\n\", val, test.res[[option]]$P[1])) } # plot results plot(test.res[[option]]) } #> #> ---- Computing European call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 1e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0225e+01 1.0225e+01 1.6140e+02 1.6140e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.1300e-01 1.0416e+01 4.4386e+00 2.0116e+02 2.0359e+01 2.4583e-01 4.0000e+00 #> 2 3.0142e-02 1.0443e+01 1.0682e+00 2.1343e+02 1.2848e+01 3.8346e-02 1.6000e+01 #> 3 5.6439e-03 1.0436e+01 2.7167e-01 2.1522e+02 7.6217e+00 1.4220e-01 6.4000e+01 #> 4 1.0348e-03 1.0459e+01 6.9123e-02 2.1671e+02 6.3099e+00 2.5154e-01 2.5600e+02 #> 5 5.4423e-04 1.0441e+01 1.7231e-02 2.1604e+02 5.9106e+00 2.1656e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.208927 (exponent for MLMC weak convergence) #> beta = 1.996768 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0444e+01 4.649e+07 2.959e+09 63.64 19982970 1663468 409221 102841 26282 #> 0.0100 1.0438e+01 8.422e+06 1.837e+08 21.81 4251529 354397 85970 21517 #> 0.0200 1.0456e+01 2.123e+06 4.591e+07 21.63 1067991 87921 21861 5521 #> 0.0500 1.0396e+01 2.416e+05 1.821e+06 7.54 141217 13256 2963 #> 0.1000 1.0445e+01 6.352e+04 4.553e+05 7.17 35109 3102 1000 #> #> #> Exact value: 10.450584, MLMC value: 10.444362 #> #> ---- Computing Asian call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 1e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 5.1068e+00 5.1068e+00 4.0327e+01 4.0327e+01 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 5.9794e-01 5.7065e+00 1.5850e+01 5.7667e+01 4.8820e+00 3.2165e-02 4.0000e+00 #> 2 4.9532e-02 5.7497e+00 1.4223e+00 6.2082e+01 5.9670e+00 1.2643e-01 1.6000e+01 #> 3 5.0397e-03 5.7722e+00 1.5257e-01 6.3261e+01 6.1551e+00 3.5811e-01 6.4000e+01 #> 4 1.1640e-03 5.7537e+00 2.4858e-02 6.3307e+01 5.9880e+00 4.0786e-01 2.5600e+02 #> 5 2.1230e-04 5.7639e+00 5.3853e-03 6.3626e+01 5.6941e+00 2.0749e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.833053 (exponent for MLMC weak convergence) #> beta = 2.888474 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 5.7646e+00 2.729e+07 2.159e+08 7.91 7655860 2406902 360400 66221 #> 0.0100 5.7467e+00 6.825e+06 5.398e+07 7.91 1912554 602189 90182 16571 #> 0.0200 5.7810e+00 1.709e+06 1.350e+07 7.90 479306 149650 22718 4175 #> 0.0500 5.7230e+00 1.956e+05 5.298e+05 2.71 65724 20500 2990 #> 0.1000 5.6500e+00 5.200e+04 1.324e+05 2.55 16025 4993 1000 #> #> #> Exact value unknown, MLMC value: 5.764555 #> #> ---- Computing lookback call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 1e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 2.0655e+01 2.0655e+01 1.7531e+02 1.7531e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 -2.5126e+00 1.8139e+01 1.3973e+01 1.9931e+02 4.5082e+00 3.3656e-02 4.0000e+00 #> 2 -6.8917e-01 1.7464e+01 4.8781e+00 2.0900e+02 3.9911e+00 1.4922e-01 1.6000e+01 #> 3 -1.7874e-01 1.7256e+01 1.4370e+00 2.1157e+02 3.7921e+00 3.2822e-01 6.4000e+01 #> 4 -4.4906e-02 1.7241e+01 3.8719e-01 2.1320e+02 3.7138e+00 3.4186e-01 2.5600e+02 #> 5 -1.1632e-02 1.7229e+01 1.0042e-01 2.1343e+02 3.6632e+00 1.2626e-03 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 1.944965 (exponent for MLMC weak convergence) #> beta = 1.789603 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0100 1.7222e+01 4.765e+07 2.914e+09 61.15 10554014 1487827 440827 119886 30901 8310 #> 0.0200 1.7237e+01 1.194e+07 7.285e+08 61.00 2643654 372982 110106 29862 7780 2092 #> 0.0500 1.7165e+01 1.892e+06 1.166e+08 61.61 420456 58811 17380 4908 1212 326 #> 0.1000 1.6962e+01 4.433e+05 2.914e+07 65.74 101158 14254 4198 1125 258 78 #> 0.2000 1.7408e+01 5.640e+04 4.513e+05 8.00 17345 2453 1000 207 #> #> #> Exact value: 17.216802, MLMC value: 17.222393 #> #> ---- Computing digital call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 4e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 5.6943e+01 5.6943e+01 2.1741e+03 2.1741e+03 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 -2.7954e+00 5.4125e+01 2.5809e+02 2.2190e+03 3.2059e+01 1.3674e-01 4.0000e+00 #> 2 -6.9818e-01 5.3471e+01 1.6582e+02 2.2272e+03 5.4104e+01 2.7114e-01 1.6000e+01 #> 3 -1.7177e-01 5.3314e+01 8.5629e+01 2.2290e+03 1.0556e+02 9.8189e-02 6.4000e+01 #> 4 -4.2758e-02 5.3243e+01 4.3557e+01 2.2298e+03 2.0771e+02 1.8516e-01 2.5600e+02 #> 5 -9.1318e-03 5.3243e+01 2.1856e+01 2.2298e+03 4.1399e+02 5.7742e-02 1.0240e+03 #> #> WARNING: kurtosis on finest level = 413.989826 #> indicates MLMC correction dominated by a few rare paths; #> for information on the connection to variance of sample variances, #> see http://mathworld.wolfram.com/SampleVarianceDistribution.html #> #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.054519 (exponent for MLMC weak convergence) #> beta = 0.905215 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0200 5.3238e+01 7.198e+08 7.611e+09 10.57 72212192 12465191 4976067 1809513 638892 233175 #> 0.0500 5.3243e+01 5.106e+07 3.044e+08 5.96 7693372 1323219 532130 187664 68565 #> 0.1000 5.3226e+01 1.302e+07 7.611e+07 5.84 1942663 334172 130755 47694 17964 #> 0.2000 5.3301e+01 1.442e+06 4.755e+06 3.30 323329 55831 22220 8442 #> 0.5000 5.3518e+01 2.349e+05 7.608e+05 3.24 52202 8958 3456 1431 #> #> #> Exact value: 53.232482, MLMC value: 53.237966 #> #> ---- Computing Heston model ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 2e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0217e+01 1.0217e+01 1.6116e+02 1.6116e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.1361e-01 1.0424e+01 3.5554e+00 1.9063e+02 1.5022e+01 1.1127e-01 4.0000e+00 #> 2 3.2716e-02 1.0424e+01 3.7040e+00 1.9165e+02 7.4001e+00 5.1720e-01 1.6000e+01 #> 3 5.2579e-03 1.0442e+01 1.7502e+00 1.9157e+02 6.1162e+00 2.0107e-01 6.4000e+01 #> 4 1.3222e-03 1.0449e+01 5.1204e-01 1.9160e+02 5.5678e+00 9.7420e-02 2.5600e+02 #> 5 1.2331e-04 1.0477e+01 1.3359e-01 1.9208e+02 5.4375e+00 4.6277e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.614583 (exponent for MLMC weak convergence) #> beta = 1.232292 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0456e+01 6.441e+07 6.539e+08 10.15 23522225 1747622 890878 306918 #> 0.0100 1.0453e+01 1.606e+07 1.635e+08 10.18 5872993 434922 222298 76339 #> 0.0200 1.0466e+01 1.956e+06 1.022e+07 5.23 1024914 76452 39061 #> 0.0500 1.0467e+01 3.128e+05 1.635e+06 5.23 163241 12489 6228 #> 0.1000 1.0485e+01 8.505e+04 4.088e+05 4.81 44380 3584 1646 #> #> #> Exact value unknown, MLMC value: 10.456461 # } # The level sampler can be called directly to retrieve the relevant level sums: opre_l(l = 7, N = 10, option = 1) #> $sums #> [1] 2.790908e-01 1.932997e-02 1.494244e-03 1.232423e-04 1.698023e+02 #> [6] 4.757903e+03 #> #> $cost #> [1] 163840 #>"},{"path":"https://mlmc.louisaslett.com/reference/plot.mlmc.test.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot an mlmc.test object — plot.mlmc.test","title":"Plot an mlmc.test object — plot.mlmc.test","text":"Produces diagnostic plots result mlmc.test function call.","code":""},{"path":"https://mlmc.louisaslett.com/reference/plot.mlmc.test.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot an mlmc.test object — plot.mlmc.test","text":"","code":"# S3 method for class 'mlmc.test' plot(x, which = \"all\", cols = NA, ...)"},{"path":"https://mlmc.louisaslett.com/reference/plot.mlmc.test.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot an mlmc.test object — plot.mlmc.test","text":"x mlmc.test object produced call mlmc.test function. vector strings specifying plots produce, \"\" diagnostic plots options : \"var\" = \\(\\log_2\\) variance level; \"mean\" = \\(\\log_2\\) absolute value mean level; \"consis\" = consistency level; \"kurt\" = kurtosis level; \"Nl\" = \\(\\log_2\\) number samples level; \"cost\" = \\(\\log_{10}\\) cost \\(\\log_{10}\\) epsilon (accuracy). cols number columns across plot override default value. ... additional arguments passed plotting functions.","code":""},{"path":"https://mlmc.louisaslett.com/reference/plot.mlmc.test.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot an mlmc.test object — plot.mlmc.test","text":"return value, called side effects.","code":""},{"path":"https://mlmc.louisaslett.com/reference/plot.mlmc.test.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot an mlmc.test object — plot.mlmc.test","text":"plots produced relatively self-explanatory. However, consistency kurtosis plots particular may require background. highly recommended refer Section 3.3 Giles (2015), rationale diagnostic plots addressed full detail.","code":""},{"path":"https://mlmc.louisaslett.com/reference/plot.mlmc.test.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Plot an mlmc.test object — plot.mlmc.test","text":"Giles, M.B. (2015) 'Multilevel Monte Carlo methods', Acta Numerica, 24, pp. 259–328. Available : doi:10.1017/S096249291500001X .","code":""},{"path":"https://mlmc.louisaslett.com/reference/plot.mlmc.test.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Plot an mlmc.test object — plot.mlmc.test","text":"Louis Aslett ","code":""},{"path":"https://mlmc.louisaslett.com/reference/plot.mlmc.test.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot an mlmc.test object — plot.mlmc.test","text":"","code":"# \\donttest{ tst <- mlmc.test(opre_l, N = 2000000, L = 5, N0 = 1000, eps.v = c(0.005, 0.01, 0.02, 0.05, 0.1), Lmin = 2, Lmax = 6, option = 1) #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 2e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0199e+01 1.0199e+01 1.6089e+02 1.6089e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.0746e-01 1.0403e+01 4.4448e+00 2.0078e+02 1.9899e+01 5.5811e-02 4.0000e+00 #> 2 2.9638e-02 1.0433e+01 1.0627e+00 2.1254e+02 1.2099e+01 7.8670e-03 1.6000e+01 #> 3 5.5601e-03 1.0424e+01 2.7202e-01 2.1487e+02 7.4630e+00 2.2499e-01 6.4000e+01 #> 4 1.2735e-03 1.0434e+01 6.8866e-02 2.1629e+02 6.2753e+00 1.3990e-01 2.5600e+02 #> 5 4.3712e-04 1.0471e+01 1.7275e-02 2.1673e+02 5.9212e+00 5.7427e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.232166 (exponent for MLMC weak convergence) #> beta = 1.996237 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0451e+01 4.621e+07 2.953e+09 63.90 19931030 1650675 405130 102836 25843 #> 0.0100 1.0447e+01 8.422e+06 1.834e+08 21.77 4252711 351640 86157 21635 #> 0.0200 1.0431e+01 2.130e+06 4.584e+07 21.52 1068631 89774 21647 5566 #> 0.0500 1.0459e+01 2.405e+05 1.814e+06 7.54 142383 12790 2937 #> 0.1000 1.0505e+01 6.535e+04 4.534e+05 6.94 36775 3144 1000 #> tst #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 2e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0199e+01 1.0199e+01 1.6089e+02 1.6089e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.0746e-01 1.0403e+01 4.4448e+00 2.0078e+02 1.9899e+01 5.5811e-02 4.0000e+00 #> 2 2.9638e-02 1.0433e+01 1.0627e+00 2.1254e+02 1.2099e+01 7.8670e-03 1.6000e+01 #> 3 5.5601e-03 1.0424e+01 2.7202e-01 2.1487e+02 7.4630e+00 2.2499e-01 6.4000e+01 #> 4 1.2735e-03 1.0434e+01 6.8866e-02 2.1629e+02 6.2753e+00 1.3990e-01 2.5600e+02 #> 5 4.3712e-04 1.0471e+01 1.7275e-02 2.1673e+02 5.9212e+00 5.7427e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.232166 (exponent for MLMC weak convergence) #> beta = 1.996237 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0451e+01 4.621e+07 2.953e+09 63.90 19931030 1650675 405130 102836 25843 #> 0.0100 1.0447e+01 8.422e+06 1.834e+08 21.77 4252711 351640 86157 21635 #> 0.0200 1.0431e+01 2.130e+06 4.584e+07 21.52 1068631 89774 21647 5566 #> 0.0500 1.0459e+01 2.405e+05 1.814e+06 7.54 142383 12790 2937 #> 0.1000 1.0505e+01 6.535e+04 4.534e+05 6.94 36775 3144 1000 #> plot(tst) # }"},{"path":"https://mlmc.louisaslett.com/news/index.html","id":"mlmc-211","dir":"Changelog","previous_headings":"","what":"mlmc 2.1.1","title":"mlmc 2.1.1","text":"Bug fix parallel processing main driver mlmc.test (thanks Qian Xin, University Bristol, bug report).","code":""},{"path":"https://mlmc.louisaslett.com/news/index.html","id":"mlmc-210","dir":"Changelog","previous_headings":"","what":"mlmc 2.1.0","title":"mlmc 2.1.0","text":"CRAN release: 2024-11-08 Add parameter value checks mlmc.test. Allow user specify alpha, beta, gamma mlmc.test, rather forcing estimation linear regression. Note departure original Matlab code, left unspecified results Matlab reproduced. Improve specificity argument documentation mlmc.test.","code":""},{"path":"https://mlmc.louisaslett.com/news/index.html","id":"mlmc-202","dir":"Changelog","previous_headings":"","what":"mlmc 2.0.2","title":"mlmc 2.0.2","text":"CRAN release: 2024-09-04 Package removed CRAN didn’t notice old Oxford email address wasn’t forwarding longer. order comply CRAN changes, C++ routines now registered maintainer info updated Durham email. User level sampling functions must now also return total cost samples simulated level. Therefore user level sampler functions must return list sums cost element. gamma argument longer required, since used automatic cost computation, can estimated alpha beta. mlmc.test() longer takes M, level refinement factor, since used calculate cost N*M^l. Per comment, user now defines cost completely via return level sampler function. Along lines, mlmc.test() now uses user returned cost places: previously CPU time measured cost convergence tests section, whilst MLMC complexity tests previously forced costs N*M^l. () old bugs squashed Euler-Maruyama discretisation level sampler, opre_l() affected lookback call Heston model options. managed get hold Matlab license, now confirmed examples docs return (within sampling variability) results Euler-Maruyama Milstein discretisation example level sampler functions. now hex sticker! hopefully fairly self explanatory: many fast simulations done low levels (lots dice, hare running bottom stairs); fewer simulations done higher levels (fewer dice go step, tortoise fewest dice top step)! now documentation website https://mlmc.louisaslett.com/","code":""},{"path":"https://mlmc.louisaslett.com/news/index.html","id":"mlmc-100","dir":"Changelog","previous_headings":"","what":"mlmc 1.0.0","title":"mlmc 1.0.0","text":"CRAN release: 2016-04-24 Initial CRAN submission.","code":""}] +[{"path":"https://mlmc.louisaslett.com/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Louis Aslett. Maintainer, author, translator. Mike Giles. Contributor. Tigran Nagapetyan. Contributor. Sebastian Vollmer. Contributor.","code":""},{"path":"https://mlmc.louisaslett.com/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Aslett L (2024). mlmc: Multi-Level Monte Carlo. R package version 2.1.1, https://github.com/louisaslett/mlmc, https://mlmc.louisaslett.com/.","code":"@Manual{, title = {mlmc: Multi-Level Monte Carlo}, author = {Louis Aslett}, year = {2024}, note = {R package version 2.1.1, https://github.com/louisaslett/mlmc}, url = {https://mlmc.louisaslett.com/}, }"},{"path":"https://mlmc.louisaslett.com/index.html","id":"mlmc-r-package-","dir":"","previous_headings":"","what":"Multi-Level Monte Carlo","title":"Multi-Level Monte Carlo","text":"implementation Multi-level Monte Carlo R. package builds original GPL-2 Matlab C++ implementations Mike Giles (see https://people.maths.ox.ac.uk/~gilesm/mlmc/) provide full MLMC driver example level samplers. Multi-core parallel sampling levels provided built-.","code":""},{"path":"https://mlmc.louisaslett.com/index.html","id":"contact","dir":"","previous_headings":"","what":"Contact","title":"Multi-Level Monte Carlo","text":"Please feel free : submit suggestions bug-reports : https://github.com/louisaslett/mlmc/issues compose e-mail : louis.aslett@durham.ac.uk","code":""},{"path":"https://mlmc.louisaslett.com/index.html","id":"install","dir":"","previous_headings":"","what":"Install","title":"Multi-Level Monte Carlo","text":"can install latest stable release directly CRAN. can install latest release candidate binary r-universe:","code":"install.packages(\"mlmc\") install.packages(\"mlmc\", repos = c(\"https://louisaslett.r-universe.dev\", options(\"repos\")[[1]]))"},{"path":"https://mlmc.louisaslett.com/index.html","id":"install-development-version-not-recommended","dir":"","previous_headings":"","what":"Install development version (not recommended)","title":"Multi-Level Monte Carlo","text":"Installing directly GitHub supported install.packages command. use devtools package install development version desired. releases, tree/commit CRAN releases made recorded, historic source can downloaded .","code":"install.packages(\"devtools\") devtools::install_github(\"louisaslett/mlmc\")"},{"path":"https://mlmc.louisaslett.com/index.html","id":"acknowledgements","dir":"","previous_headings":"","what":"Acknowledgements","title":"Multi-Level Monte Carlo","text":"Louis Aslett supported -like programme grant (EPSRC grant reference number EP/K014463/1 http://www.-like.org.uk) package first conceived. Tigran Nagapetyan Sebastian Vollmer supported EPSRC Grant EP/N000188/1.","code":""},{"path":"https://mlmc.louisaslett.com/index.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Multi-Level Monte Carlo","text":"use software, please cite: Aslett, L. J. M., Giles, M. B., Nagapetyan, T. Vollmer, S. J. (2016), mlmc: Multi-Level Monte Carlo. R package. DOI: 10.32614/CRAN.package.mlmc https://CRAN.R-project.org/package=mlmc Thank-.","code":"@Manual{mlmcpkg, title = {mlmc: Multi-Level Monte Carlo}, author = {Aslett, L. J. M. and Giles, M. B. and Nagapetyan, T. and Vollmer, S. J.}, year = {2016}, note = {R package}, doi = {10.32614/CRAN.package.mlmc}, url = {https://CRAN.R-project.org/package=mlmc} }"},{"path":"https://mlmc.louisaslett.com/reference/mcqmc06_l.html","id":null,"dir":"Reference","previous_headings":"","what":"Financial options using a Milstein discretisation — mcqmc06_l","title":"Financial options using a Milstein discretisation — mcqmc06_l","text":"Financial options based scalar geometric Brownian motion, similar Mike Giles' MCQMC06 paper, Giles (2008), using Milstein discretisation.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mcqmc06_l.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Financial options using a Milstein discretisation — mcqmc06_l","text":"","code":"mcqmc06_l(l, N, option)"},{"path":"https://mlmc.louisaslett.com/reference/mcqmc06_l.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Financial options using a Milstein discretisation — mcqmc06_l","text":"l level simulated. N number samples computed. option option type, 1 5. options : 1 = European call; 2 = Asian call; 3 = lookback call; 4 = digital call; 5 = barrier call.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mcqmc06_l.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Financial options using a Milstein discretisation — mcqmc06_l","text":"named list containing: sums vector length six \\(\\left(\\sum Y_i, \\sum Y_i^2, \\sum Y_i^3, \\sum Y_i^4, \\sum X_i, \\sum X_i^2\\right)\\) \\(Y_i\\) iid simulations expectation \\(E[P_0]\\) \\(l=0\\) expectation \\(E[P_l-P_{l-1}]\\) \\(l>0\\), \\(X_i\\) iid simulations expectation \\(E[P_l]\\). Note first two components used main mlmc() driver, full vector used mlmc.test() convergence tests etc; cost scalar total cost paths simulated, computed \\(N \\times 2^l\\) level \\(l\\).","code":""},{"path":"https://mlmc.louisaslett.com/reference/mcqmc06_l.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Financial options using a Milstein discretisation — mcqmc06_l","text":"function based GPL-2 C++ code Mike Giles.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mcqmc06_l.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Financial options using a Milstein discretisation — mcqmc06_l","text":"Giles, M. (2008) 'Improved Multilevel Monte Carlo Convergence using Milstein Scheme', . Keller, S. Heinrich, H. Niederreiter (eds) Monte Carlo Quasi-Monte Carlo Methods 2006. Berlin, Heidelberg: Springer, pp. 343–358. Available : doi:10.1007/978-3-540-74496-2_20 .","code":""},{"path":"https://mlmc.louisaslett.com/reference/mcqmc06_l.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Financial options using a Milstein discretisation — mcqmc06_l","text":"Louis Aslett Mike Giles ","code":""},{"path":"https://mlmc.louisaslett.com/reference/mcqmc06_l.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Financial options using a Milstein discretisation — mcqmc06_l","text":"","code":"# \\donttest{ # These are similar to the MLMC tests for the MCQMC06 paper # using a Milstein discretisation with 2^l timesteps on level l # # The figures are slightly different due to: # -- change in MSE split # -- change in cost calculation # -- different random number generation # -- switch to S_0=100 # # Note the following takes quite a while to run, for a toy example see after # this block. N0 <- 200 # initial samples on coarse levels Lmin <- 2 # minimum refinement level Lmax <- 10 # maximum refinement level test.res <- list() for(option in 1:5) { if(option == 1) { cat(\"\\n ---- Computing European call ---- \\n\") N <- 20000 # samples for convergence tests L <- 8 # levels for convergence tests Eps <- c(0.005, 0.01, 0.02, 0.05, 0.1) } else if(option == 2) { cat(\"\\n ---- Computing Asian call ---- \\n\") N <- 20000 # samples for convergence tests L <- 8 # levels for convergence tests Eps <- c(0.005, 0.01, 0.02, 0.05, 0.1) } else if(option == 3) { cat(\"\\n ---- Computing lookback call ---- \\n\") N <- 20000 # samples for convergence tests L <- 10 # levels for convergence tests Eps <- c(0.005, 0.01, 0.02, 0.05, 0.1) } else if(option == 4) { cat(\"\\n ---- Computing digital call ---- \\n\") N <- 200000 # samples for convergence tests L <- 8 # levels for convergence tests Eps <- c(0.01, 0.02, 0.05, 0.1, 0.2) } else if(option == 5) { cat(\"\\n ---- Computing barrier call ---- \\n\") N <- 200000 # samples for convergence tests L <- 8 # levels for convergence tests Eps <- c(0.005, 0.01, 0.02, 0.05, 0.1) } test.res[[option]] <- mlmc.test(mcqmc06_l, N, L, N0, Eps, Lmin, Lmax, option = option) # print exact analytic value, based on S0=K T <- 1 r <- 0.05 sig <- 0.2 K <- 100 B <- 0.85*K k <- 0.5*sig^2/r; d1 <- (r+0.5*sig^2)*T / (sig*sqrt(T)) d2 <- (r-0.5*sig^2)*T / (sig*sqrt(T)) d3 <- (2*log(B/K) + (r+0.5*sig^2)*T) / (sig*sqrt(T)) d4 <- (2*log(B/K) + (r-0.5*sig^2)*T) / (sig*sqrt(T)) if(option == 1) { val <- K*( pnorm(d1) - exp(-r*T)*pnorm(d2) ) } else if(option == 2) { val <- NA } else if(option == 3) { val <- K*( pnorm(d1) - pnorm(-d1)*k - exp(-r*T)*(pnorm(d2) - pnorm(d2)*k) ) } else if(option == 4) { val <- K*exp(-r*T)*pnorm(d2) } else if(option == 5) { val <- K*( pnorm(d1) - exp(-r*T)*pnorm(d2) - ((K/B)^(1-1/k))*((B^2)/(K^2)*pnorm(d3) - exp(-r*T)*pnorm(d4)) ) } if(is.na(val)) { cat(sprintf(\"\\n Exact value unknown, MLMC value: %f \\n\", test.res[[option]]$P[1])) } else { cat(sprintf(\"\\n Exact value: %f, MLMC value: %f \\n\", val, test.res[[option]]$P[1])) } # plot results plot(test.res[[option]]) } #> #> ---- Computing European call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 20000 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0030e+01 1.0030e+01 1.9725e+02 1.9725e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 1.8716e-01 1.0359e+01 1.6531e-01 2.0988e+02 9.8531e+01 2.3102e-01 2.0000e+00 #> 2 1.0142e-01 1.0191e+01 4.1839e-02 2.0683e+02 2.8282e+01 4.3754e-01 4.0000e+00 #> 3 5.5153e-02 1.0558e+01 1.2325e-02 2.1670e+02 2.1426e+01 5.0386e-01 8.0000e+00 #> 4 2.7904e-02 1.0468e+01 3.2321e-03 2.1466e+02 1.7647e+01 1.8893e-01 1.6000e+01 #> 5 1.3913e-02 1.0420e+01 8.2640e-04 2.1465e+02 1.2310e+01 9.9685e-02 3.2000e+01 #> 6 7.2131e-03 1.0479e+01 2.1421e-04 2.1745e+02 1.1577e+01 8.2241e-02 6.4000e+01 #> 7 3.5650e-03 1.0475e+01 5.2975e-05 2.1736e+02 1.0232e+01 1.0760e-02 1.2800e+02 #> 8 1.7857e-03 1.0545e+01 1.3436e-05 2.1571e+02 1.0093e+01 1.0816e-01 2.5600e+02 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.963583 (exponent for MLMC weak convergence) #> beta = 1.937392 (exponent for MLMC variance) #> gamma = 1.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0458e+01 1.361e+07 2.945e+09 216.36 11917020 231958 98151 33333 12301 4375 1552 615 223 #> 0.0100 1.0439e+01 3.356e+06 3.710e+08 110.52 2953179 65020 21963 7800 2913 1068 386 136 #> 0.0200 1.0470e+01 8.371e+05 4.639e+07 55.41 740921 14276 5398 2185 776 293 106 #> 0.0500 1.0461e+01 1.312e+05 3.663e+06 27.93 117176 2060 829 365 132 48 #> 0.1000 1.0304e+01 3.137e+04 4.579e+05 14.60 28620 543 200 64 22 #> #> #> Exact value: 10.450584, MLMC value: 10.458105 #> #> ---- Computing Asian call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 20000 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 5.6185e+00 5.6185e+00 6.0313e+01 6.0313e+01 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 4.1755e-02 5.6931e+00 2.6371e-01 6.2423e+01 2.3578e+01 9.5912e-02 2.0000e+00 #> 2 3.9962e-02 5.7058e+00 3.7704e-02 6.1951e+01 1.2360e+01 8.0573e-02 4.0000e+00 #> 3 2.7370e-02 5.7290e+00 6.0579e-03 6.2682e+01 8.1099e+00 1.2570e-02 8.0000e+00 #> 4 1.5138e-02 5.7909e+00 1.2289e-03 6.4331e+01 7.6054e+00 1.3822e-01 1.6000e+01 #> 5 7.5845e-03 5.7123e+00 2.6881e-04 6.3121e+01 7.4456e+00 2.5437e-01 3.2000e+01 #> 6 3.8863e-03 5.6738e+00 6.2498e-05 6.1495e+01 7.9930e+00 1.2635e-01 6.4000e+01 #> 7 1.9756e-03 5.7571e+00 1.5521e-05 6.2941e+01 7.8415e+00 2.4282e-01 1.2800e+02 #> 8 1.0065e-03 5.8278e+00 3.8637e-06 6.4531e+01 7.4338e+00 2.0594e-01 2.5600e+02 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.818556 (exponent for MLMC weak convergence) #> beta = 2.269413 (exponent for MLMC variance) #> gamma = 1.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 5.7609e+00 4.738e+06 8.811e+08 185.94 3878099 176768 48852 15162 4375 1512 497 178 67 #> 0.0100 5.7537e+00 1.407e+06 1.074e+08 76.37 1189144 44761 13058 3745 1110 392 142 50 #> 0.0200 5.7585e+00 2.909e+05 1.312e+07 45.09 239760 10909 2985 928 289 104 32 #> 0.0500 5.7167e+00 4.541e+04 1.077e+06 23.72 37708 1729 451 149 48 15 #> 0.1000 5.6693e+00 1.250e+04 1.372e+05 10.98 10250 429 200 38 18 #> #> #> Exact value unknown, MLMC value: 5.760949 #> #> ---- Computing lookback call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 20000 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.7603e+01 1.7603e+01 1.8757e+02 1.8757e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 -1.1974e-01 1.7458e+01 1.4071e+00 1.9666e+02 9.2816e+00 4.0921e-02 2.0000e+00 #> 2 -1.3427e-01 1.7475e+01 5.0942e-01 2.0891e+02 9.1129e+00 2.4391e-01 4.0000e+00 #> 3 -8.8887e-02 1.7226e+01 1.4282e-01 2.0632e+02 9.4423e+00 2.5918e-01 8.0000e+00 #> 4 -5.4996e-02 1.7188e+01 4.0886e-02 2.1052e+02 8.3295e+00 2.7305e-02 1.6000e+01 #> 5 -2.6679e-02 1.7198e+01 1.0245e-02 2.1394e+02 8.6646e+00 5.9360e-02 3.2000e+01 #> 6 -1.4201e-02 1.7086e+01 2.6724e-03 2.0766e+02 8.6317e+00 1.5823e-01 6.4000e+01 #> 7 -7.2594e-03 1.7233e+01 6.7415e-04 2.1055e+02 7.3269e+00 2.5092e-01 1.2800e+02 #> 8 -3.5000e-03 1.7275e+01 1.6549e-04 2.1712e+02 7.9473e+00 7.3983e-02 2.5600e+02 #> 9 -1.7809e-03 1.7173e+01 4.1676e-05 2.1442e+02 7.3364e+00 1.6080e-01 5.1200e+02 #> 10 -8.6176e-04 1.7440e+01 1.0424e-05 2.1902e+02 8.6798e+00 4.2827e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.852889 (exponent for MLMC weak convergence) #> beta = 1.920578 (exponent for MLMC variance) #> gamma = 1.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.7220e+01 2.197e+07 1.196e+10 544.53 14695671 908426 378089 146440 54138 19500 6933 2469 917 332 113 #> 0.0100 1.7227e+01 5.350e+06 7.411e+08 138.53 3626992 222962 92265 36156 13314 4941 1741 615 223 #> 0.0200 1.7201e+01 1.334e+06 1.853e+08 138.92 902716 55846 23242 9121 3370 1208 430 150 55 #> 0.0500 1.7265e+01 2.030e+05 7.088e+06 34.92 141854 8734 3548 1379 508 186 68 #> 0.1000 1.7118e+01 5.179e+04 1.772e+06 34.21 35378 2295 934 393 137 50 18 #> #> #> Exact value: 17.216802, MLMC value: 17.220350 #> #> ---- Computing digital call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 2e+05 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 5.6951e+01 5.6951e+01 1.0000e-10 1.0000e-10 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 -2.7021e+00 5.4263e+01 2.0431e-01 7.2354e+02 1.1150e+01 7.9904e-02 2.0000e+00 #> 2 -7.1604e-01 5.3580e+01 1.9385e+00 1.1897e+03 1.9612e+01 7.8338e-02 4.0000e+00 #> 3 -2.0194e-01 5.3346e+01 1.2403e+00 1.5085e+03 2.2141e+01 6.4013e-02 8.0000e+00 #> 4 -5.9328e-02 5.3352e+01 5.4685e-01 1.7222e+03 2.7503e+01 1.2010e-01 1.6000e+01 #> 5 -2.2149e-02 5.3216e+01 2.1220e-01 1.8724e+03 4.3452e+01 1.9886e-01 3.2000e+01 #> 6 -7.9524e-03 5.3246e+01 7.8848e-02 1.9789e+03 5.6893e+01 6.2962e-02 6.4000e+01 #> 7 -3.6181e-03 5.3389e+01 2.7991e-02 2.0497e+03 8.0117e+01 2.4439e-01 1.2800e+02 #> 8 -1.2441e-03 5.3354e+01 1.0449e-02 2.1024e+03 1.1769e+02 5.5995e-02 2.5600e+02 #> #> WARNING: kurtosis on finest level = 117.692596 #> indicates MLMC correction dominated by a few rare paths; #> for information on the connection to variance of sample variances, #> see http://mathworld.wolfram.com/SampleVarianceDistribution.html #> #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 1.561395 (exponent for MLMC weak convergence) #> beta = 0.879603 (exponent for MLMC variance) #> gamma = 1.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0100 5.3242e+01 3.755e+06 3.498e+09 931.64 200 71109 155815 88148 41078 17950 8299 4072 #> 0.0200 5.3237e+01 7.650e+05 4.222e+08 551.88 200 16210 34921 20467 9378 4267 2224 #> 0.0500 5.3256e+01 1.001e+05 3.195e+07 319.11 200 2404 4796 2991 1591 830 #> 0.1000 5.3214e+01 1.210e+04 3.674e+06 303.70 200 381 842 475 248 #> 0.2000 5.3294e+01 4.020e+03 9.185e+05 228.49 200 200 283 140 73 #> #> #> Exact value: 53.232482, MLMC value: 53.241652 #> #> ---- Computing barrier call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 2e+05 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 9.4564e+00 9.4564e+00 1.8871e+02 1.8871e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 1.6056e-01 9.6193e+00 1.7069e-01 1.9914e+02 6.1603e+01 1.2323e-02 2.0000e+00 #> 2 1.4474e-01 9.6700e+00 1.5745e-01 2.0464e+02 1.0612e+02 4.8690e-01 4.0000e+00 #> 3 9.8315e-02 9.8418e+00 1.4427e-01 2.1162e+02 3.9947e+02 3.7507e-01 8.0000e+00 #> 4 4.6888e-02 9.9143e+00 5.1685e-02 2.1567e+02 1.5447e+03 1.2963e-01 1.6000e+01 #> 5 2.0359e-02 9.9093e+00 1.0326e-02 2.1578e+02 1.2857e+03 1.2834e-01 3.2000e+01 #> 6 1.0032e-02 9.9355e+00 4.2701e-03 2.1714e+02 3.9267e+03 8.1491e-02 6.4000e+01 #> 7 4.8781e-03 9.9329e+00 1.1130e-03 2.1622e+02 1.7346e+03 3.7701e-02 1.2800e+02 #> 8 2.3827e-03 9.9133e+00 4.1529e-04 2.1690e+02 6.9372e+03 1.1119e-01 2.5600e+02 #> #> WARNING: kurtosis on finest level = 6937.174649 #> indicates MLMC correction dominated by a few rare paths; #> for information on the connection to variance of sample variances, #> see http://mathworld.wolfram.com/SampleVarianceDistribution.html #> #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.929256 (exponent for MLMC weak convergence) #> beta = 1.357869 (exponent for MLMC variance) #> gamma = 1.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 9.9433e+00 2.155e+07 5.923e+09 274.79 14584932 310729 219105 148864 56194 21897 10346 7173 2550 873 #> 0.0100 9.9355e+00 4.662e+06 7.403e+08 158.79 3394165 72037 49865 32362 13511 5756 2045 645 203 #> 0.0200 9.9761e+00 1.264e+06 9.225e+07 72.96 883634 18369 12864 8275 3246 2341 951 302 #> 0.0500 9.8703e+00 1.638e+05 7.412e+06 45.25 127079 2734 2077 943 407 169 54 #> 0.1000 9.7337e+00 3.815e+04 9.207e+05 24.13 30393 711 400 260 98 34 #> #> #> Exact value: 9.949270, MLMC value: 9.943268 # } # The level sampler can be called directly to retrieve the relevant level sums: mcqmc06_l(l = 7, N = 10, option = 1) #> $sums #> [1] 2.648764e-02 2.889784e-04 3.607043e-06 5.105926e-08 1.032765e+02 #> [6] 2.338980e+03 #> #> $cost #> [1] 1280 #>"},{"path":"https://mlmc.louisaslett.com/reference/mlmc.html","id":null,"dir":"Reference","previous_headings":"","what":"Multi-level Monte Carlo estimation — mlmc","title":"Multi-level Monte Carlo estimation — mlmc","text":"function Multi-level Monte Carlo driver sample levels user specified function.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Multi-level Monte Carlo estimation — mlmc","text":"","code":"mlmc( Lmin, Lmax, N0, eps, mlmc_l, alpha = NA, beta = NA, gamma = NA, parallel = NA, ... )"},{"path":"https://mlmc.louisaslett.com/reference/mlmc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Multi-level Monte Carlo estimation — mlmc","text":"Lmin minimum level refinement. Must \\(\\ge 2\\). Lmax maximum level refinement. Must \\(\\ge\\) Lmin. N0 initial number samples used first 3 levels subsequent levels automatically added. Must \\(> 0\\). eps target accuracy estimate (root mean square error). Must \\(> 0\\). mlmc_l user supplied function provides estimate level \\(l\\). must take least two arguments, first level number simulated second number paths. Additional arguments can taken desired: additional ... arguments function forwarded user defined mlmc_l function. user supplied function return named list containing one element named sums second named cost, : sums vector length least two. first two elements \\(\\left(\\sum Y_i, \\sum Y_i^2\\right)\\) \\(Y_i\\) iid simulations expectation \\(E[P_0]\\) \\(l=0\\) expectation \\(E[P_l-P_{l-1}]\\) \\(l>0\\). Note typically user supplied level sampler actually return vector length six, also enabling use mlmc.test() function perform convergence tests, kurtosis, telescoping sum checks. See mlmc.test() definition remaining four elements. cost scalar total cost paths simulated. example, financial options samplers included package, calculated \\(NM^l\\), \\(N\\) number paths requested call user function mlmc_l, \\(M\\) refinement cost factor (\\(M=2\\) mcqmc06_l() \\(M=4\\) opre_l()), \\(l\\) level sampled. See function (source code ) opre_l() mcqmc06_l() package example user supplied level samplers. alpha weak error, \\(O(2^{-\\alpha l})\\). Must \\(> 0\\) specified. NA alpha estimated. beta variance, \\(O(2^{-\\beta l})\\). Must \\(> 0\\) specified. NA beta estimated. gamma sample cost, \\(O(2^{\\gamma l})\\). Must \\(> 0\\) specified. NA gamma estimated. parallel integer supplied, R fork parallel parallel processes spread simulations required level evenly possible across cores. ... additional arguments passed user supplied mlmc_l function called.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Multi-level Monte Carlo estimation — mlmc","text":"named list containing: P MLMC estimate; Nl vector number samples performed level; Cl Per sample cost level.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Multi-level Monte Carlo estimation — mlmc","text":"Multilevel Monte Carlo Method method originated works Giles (2008) Heinrich (1998). Consider sequence \\(P_0, P_1, \\ldots\\), approximates \\(P_L\\) increasing accuracy, also increasing cost, simple identity $$E[P_L] = E[P_0] + \\sum_{l=1}^L E[P_l-P_{l-1}],$$ therefore can use following unbiased estimator \\(E[P_L]\\), $$N_0^{-1} \\sum_{n=1}^{N_0} P_0^{(0,n)} + \\sum_{l=1}^L \\left\\{ N_l^{-1} \\sum_{n=1}^{N_l} \\left(P_l^{(l,n)} - P_{l-1}^{(l,n)}\\right) \\right\\}$$ \\(N_l\\) samples produced level \\(l\\). inclusion level \\(l\\) superscript \\((l,n)\\) indicates samples used level correction independent. Set \\(C_0\\), \\(V_0\\) cost variance one sample \\(P_0\\), \\(C_l, V_l\\) cost variance one sample \\(P_l - P_{l-1}\\), overall cost variance multilevel estimator \\(\\sum_{l=0}^L N_l C_l\\) \\(\\sum_{l=0}^L N_l^{-1} V_l\\), respectively. idea behind method, provided product \\(V_l C_l\\) decreases \\(l\\), .e. cost increases level slower variance decreases, one can achieve significant computational savings, can formalised Theorem 1 Giles (2015). information multilevel Monte Carlo methods, see webpage https://people.maths.ox.ac.uk/gilesm/mlmc_community.html lists research groups working area, main publications. function based GPL-2 'Matlab' code Mike Giles.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Multi-level Monte Carlo estimation — mlmc","text":"Giles, M.B. (2008) 'Multilevel Monte Carlo Path Simulation', Operations Research, 56(3), pp. 607–617. Available : doi:10.1287/opre.1070.0496 . Giles, M.B. (2015) 'Multilevel Monte Carlo methods', Acta Numerica, 24, pp. 259–328. Available : doi:10.1017/S096249291500001X . Heinrich, S. (1998) 'Monte Carlo Complexity Global Solution Integral Equations', Journal Complexity, 14(2), pp. 151–175. Available : doi:10.1006/jcom.1998.0471 .","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Multi-level Monte Carlo estimation — mlmc","text":"Louis Aslett Mike Giles Tigran Nagapetyan ","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Multi-level Monte Carlo estimation — mlmc","text":"","code":"mlmc(2, 6, 1000, 0.01, opre_l, option = 1) #> $P #> [1] 10.44313 #> #> $Nl #> [1] 4257656 353933 99613 21890 #> #> $Cl #> [1] 1 4 16 64 #> mlmc(2, 10, 1000, 0.01, mcqmc06_l, option = 1) #> $P #> [1] 10.45051 #> #> $Nl #> [1] 2966234 58326 24428 8277 3060 1127 390 154 #> #> $Cl #> [1] 1 2 4 8 16 32 64 128 #>"},{"path":"https://mlmc.louisaslett.com/reference/mlmc.test.html","id":null,"dir":"Reference","previous_headings":"","what":"Multi-level Monte Carlo estimation test suite — mlmc.test","title":"Multi-level Monte Carlo estimation test suite — mlmc.test","text":"Computes suite diagnostic values MLMC estimation problem.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.test.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Multi-level Monte Carlo estimation test suite — mlmc.test","text":"","code":"mlmc.test( mlmc_l, N, L, N0, eps.v, Lmin, Lmax, alpha = NA, beta = NA, gamma = NA, parallel = NA, silent = FALSE, ... )"},{"path":"https://mlmc.louisaslett.com/reference/mlmc.test.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Multi-level Monte Carlo estimation test suite — mlmc.test","text":"mlmc_l user supplied function provides estimate level \\(l\\). must take least two arguments, first level number simulated second number paths. Additional arguments can taken desired: additional ... arguments function forwarded user defined mlmc_l function. user supplied function return named list containing one element named sums second named cost, : sums vector length six \\(\\left(\\sum Y_i, \\sum Y_i^2, \\sum Y_i^3, \\sum Y_i^4, \\sum X_i, \\sum X_i^2\\right)\\) \\(Y_i\\) iid simulations expectation \\(E[P_0]\\) \\(l=0\\) expectation \\(E[P_l-P_{l-1}]\\) \\(l>0\\), \\(X_i\\) iid simulations expectation \\(E[P_l]\\). Note differs main mlmc() driver, requires first two elements order calculate estimate. remaining elements required mlmc.test() since used convergence tests, kurtosis, telescoping sum checks. cost scalar total cost paths simulated. example, financial options samplers included package, calculated \\(NM^l\\), \\(N\\) number paths requested call user function mlmc_l, \\(M\\) refinement cost factor (\\(M=2\\) mcqmc06_l() \\(M=4\\) opre_l()), \\(l\\) level sampled. See function (source code ) opre_l() mcqmc06_l() package example user supplied level samplers. N number samples use convergence tests, kurtosis, telescoping sum check. L number levels use convergence tests, kurtosis, telescoping sum check. N0 initial number samples used first 3 levels subsequent levels automatically added complexity tests. Must \\(> 0\\). eps.v vector one target accuracies complexity tests. Must \\(> 0\\). Lmin minimum level refinement complexity tests. Must \\(\\ge 2\\). Lmax maximum level refinement complexity tests. Must \\(\\ge\\) Lmin. alpha weak error, \\(O(2^{-\\alpha l})\\). Must \\(> 0\\) specified. NA alpha estimated. beta variance, \\(O(2^{-\\beta l})\\). Must \\(> 0\\) specified. NA beta estimated. gamma sample cost, \\(O(2^{\\gamma l})\\). Must \\(> 0\\) specified. NA gamma estimated. parallel integer supplied, R fork parallel parallel processes. done convergence tests section splitting N samples evenly possible across cores sampling level. also done MLMC complexity tests passing parallel argument mlmc() driver targeting accuracy level eps. silent set TRUE supress running output (identical output can still printed printing return result) ... additional arguments passed user supplied mlmc_l function called","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.test.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Multi-level Monte Carlo estimation test suite — mlmc.test","text":"mlmc.test object contains computed diagnostic values. object can printed plotted (see plot.mlmc.test).","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.test.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Multi-level Monte Carlo estimation test suite — mlmc.test","text":"See one example level sampler functions (e.g. opre_l()) example usage. function based GPL-2 'Matlab' code Mike Giles.","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.test.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Multi-level Monte Carlo estimation test suite — mlmc.test","text":"Louis Aslett Mike Giles Tigran Nagapetyan ","code":""},{"path":"https://mlmc.louisaslett.com/reference/mlmc.test.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Multi-level Monte Carlo estimation test suite — mlmc.test","text":"","code":"# \\donttest{ # Example calls with realistic arguments # Financial options using an Euler-Maruyama discretisation tst <- mlmc.test(opre_l, N = 2000000, L = 5, N0 = 1000, eps.v = c(0.005, 0.01, 0.02, 0.05, 0.1), Lmin = 2, Lmax = 6, option = 1) #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 2e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0209e+01 1.0209e+01 1.6139e+02 1.6139e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.0971e-01 1.0420e+01 4.4439e+00 2.0102e+02 2.0055e+01 2.9916e-02 4.0000e+00 #> 2 2.9164e-02 1.0443e+01 1.0641e+00 2.1243e+02 1.2387e+01 9.3236e-02 1.6000e+01 #> 3 5.8030e-03 1.0457e+01 2.7256e-01 2.1538e+02 7.5182e+00 1.1818e-01 6.4000e+01 #> 4 1.6226e-03 1.0450e+01 6.8529e-02 2.1643e+02 6.2241e+00 1.3021e-01 2.5600e+02 #> 5 5.6870e-04 1.0456e+01 1.7268e-02 2.1633e+02 5.9348e+00 8.0291e-02 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.122090 (exponent for MLMC weak convergence) #> beta = 1.997195 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0449e+01 4.625e+07 2.955e+09 63.88 19941583 1650853 405719 103214 25829 #> 0.0100 1.0454e+01 8.433e+06 1.838e+08 21.80 4257398 354804 85692 21643 #> 0.0200 1.0449e+01 2.127e+06 4.595e+07 21.60 1068793 88086 22057 5520 #> 0.0500 1.0440e+01 2.519e+05 1.813e+06 7.20 159399 11284 2959 #> 0.1000 1.0495e+01 6.324e+04 4.532e+05 7.17 35177 3016 1000 #> tst #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 2e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0209e+01 1.0209e+01 1.6139e+02 1.6139e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.0971e-01 1.0420e+01 4.4439e+00 2.0102e+02 2.0055e+01 2.9916e-02 4.0000e+00 #> 2 2.9164e-02 1.0443e+01 1.0641e+00 2.1243e+02 1.2387e+01 9.3236e-02 1.6000e+01 #> 3 5.8030e-03 1.0457e+01 2.7256e-01 2.1538e+02 7.5182e+00 1.1818e-01 6.4000e+01 #> 4 1.6226e-03 1.0450e+01 6.8529e-02 2.1643e+02 6.2241e+00 1.3021e-01 2.5600e+02 #> 5 5.6870e-04 1.0456e+01 1.7268e-02 2.1633e+02 5.9348e+00 8.0291e-02 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.122090 (exponent for MLMC weak convergence) #> beta = 1.997195 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0449e+01 4.625e+07 2.955e+09 63.88 19941583 1650853 405719 103214 25829 #> 0.0100 1.0454e+01 8.433e+06 1.838e+08 21.80 4257398 354804 85692 21643 #> 0.0200 1.0449e+01 2.127e+06 4.595e+07 21.60 1068793 88086 22057 5520 #> 0.0500 1.0440e+01 2.519e+05 1.813e+06 7.20 159399 11284 2959 #> 0.1000 1.0495e+01 6.324e+04 4.532e+05 7.17 35177 3016 1000 #> plot(tst) # Financial options using a Milstein discretisation tst <- mlmc.test(mcqmc06_l, N = 20000, L = 8, N0 = 200, eps.v = c(0.005, 0.01, 0.02, 0.05, 0.1), Lmin = 2, Lmax = 10, option = 1) #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 20000 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0133e+01 1.0133e+01 1.9810e+02 1.9810e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 1.8339e-01 1.0238e+01 1.4650e-01 2.0666e+02 4.3668e+01 1.2791e-01 2.0000e+00 #> 2 1.0178e-01 1.0207e+01 4.1696e-02 2.0649e+02 3.1277e+01 2.1643e-01 4.0000e+00 #> 3 5.4679e-02 1.0390e+01 1.2096e-02 2.1192e+02 2.2094e+01 2.0862e-01 8.0000e+00 #> 4 2.7491e-02 1.0312e+01 3.0769e-03 2.1030e+02 1.2999e+01 1.7120e-01 1.6000e+01 #> 5 1.3946e-02 1.0439e+01 8.5509e-04 2.2017e+02 1.3315e+01 1.8132e-01 3.2000e+01 #> 6 6.9500e-03 1.0260e+01 2.1296e-04 2.1398e+02 1.1626e+01 2.9709e-01 6.4000e+01 #> 7 3.5764e-03 1.0542e+01 5.3863e-05 2.1728e+02 9.9385e+00 4.4704e-01 1.2800e+02 #> 8 1.8070e-03 1.0587e+01 1.3390e-05 2.1707e+02 9.4222e+00 6.9319e-02 2.5600e+02 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.960913 (exponent for MLMC weak convergence) #> beta = 1.919459 (exponent for MLMC variance) #> gamma = 1.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0447e+01 1.355e+07 2.964e+09 218.65 11903219 229699 88580 33052 12456 4446 1600 569 220 #> 0.0100 1.0438e+01 3.363e+06 3.708e+08 110.27 2957414 56143 25072 8068 2875 1106 426 155 #> 0.0200 1.0468e+01 9.014e+05 4.565e+07 50.64 795790 15288 8075 2046 735 266 96 #> 0.0500 1.0432e+01 1.313e+05 3.758e+06 28.62 116815 2610 840 297 127 46 #> 0.1000 1.0251e+01 3.492e+04 4.486e+05 12.85 31940 613 200 65 27 #> tst #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 20000 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0133e+01 1.0133e+01 1.9810e+02 1.9810e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 1.8339e-01 1.0238e+01 1.4650e-01 2.0666e+02 4.3668e+01 1.2791e-01 2.0000e+00 #> 2 1.0178e-01 1.0207e+01 4.1696e-02 2.0649e+02 3.1277e+01 2.1643e-01 4.0000e+00 #> 3 5.4679e-02 1.0390e+01 1.2096e-02 2.1192e+02 2.2094e+01 2.0862e-01 8.0000e+00 #> 4 2.7491e-02 1.0312e+01 3.0769e-03 2.1030e+02 1.2999e+01 1.7120e-01 1.6000e+01 #> 5 1.3946e-02 1.0439e+01 8.5509e-04 2.2017e+02 1.3315e+01 1.8132e-01 3.2000e+01 #> 6 6.9500e-03 1.0260e+01 2.1296e-04 2.1398e+02 1.1626e+01 2.9709e-01 6.4000e+01 #> 7 3.5764e-03 1.0542e+01 5.3863e-05 2.1728e+02 9.9385e+00 4.4704e-01 1.2800e+02 #> 8 1.8070e-03 1.0587e+01 1.3390e-05 2.1707e+02 9.4222e+00 6.9319e-02 2.5600e+02 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.960913 (exponent for MLMC weak convergence) #> beta = 1.919459 (exponent for MLMC variance) #> gamma = 1.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0447e+01 1.355e+07 2.964e+09 218.65 11903219 229699 88580 33052 12456 4446 1600 569 220 #> 0.0100 1.0438e+01 3.363e+06 3.708e+08 110.27 2957414 56143 25072 8068 2875 1106 426 155 #> 0.0200 1.0468e+01 9.014e+05 4.565e+07 50.64 795790 15288 8075 2046 735 266 96 #> 0.0500 1.0432e+01 1.313e+05 3.758e+06 28.62 116815 2610 840 297 127 46 #> 0.1000 1.0251e+01 3.492e+04 4.486e+05 12.85 31940 613 200 65 27 #> plot(tst) # } # Toy versions for CRAN tests tst <- mlmc.test(opre_l, N = 10000, L = 5, N0 = 1000, eps.v = c(0.025, 0.1), Lmin = 2, Lmax = 6, option = 1) #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 10000 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0144e+01 1.0144e+01 1.5933e+02 1.5933e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.0461e-01 1.0494e+01 4.3545e+00 2.0017e+02 1.6552e+01 1.6836e-01 4.0000e+00 #> 2 3.4172e-02 1.0188e+01 1.0920e+00 2.0313e+02 1.3486e+01 3.8611e-01 1.6000e+01 #> 3 2.7394e-03 1.0609e+01 2.7241e-01 2.1473e+02 8.9020e+00 4.7445e-01 6.4000e+01 #> 4 4.6225e-03 1.0487e+01 7.0387e-02 2.2204e+02 6.2642e+00 1.4175e-01 2.5600e+02 #> 5 2.3568e-03 1.0375e+01 1.6529e-02 2.1034e+02 5.6902e+00 1.2895e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 1.576591 (exponent for MLMC weak convergence) #> beta = 2.003820 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0250 1.0442e+01 1.352e+06 2.932e+07 21.68 682155 56440 13888 3468 #> 0.1000 1.0326e+01 6.651e+04 4.333e+05 6.52 38193 3079 1000 #> tst <- mlmc.test(mcqmc06_l, N = 10000, L = 8, N0 = 1000, eps.v = c(0.025, 0.1), Lmin = 2, Lmax = 10, option = 1) #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 10000 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 9.7083e+00 9.7083e+00 1.8872e+02 1.8872e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 1.8889e-01 1.0493e+01 1.5689e-01 2.1033e+02 4.2469e+01 6.9418e-01 2.0000e+00 #> 2 1.0293e-01 1.0345e+01 4.1077e-02 2.1021e+02 2.5473e+01 2.8726e-01 4.0000e+00 #> 3 5.2791e-02 1.0138e+01 1.1696e-02 2.1027e+02 2.0845e+01 2.9683e-01 8.0000e+00 #> 4 2.7545e-02 1.0462e+01 3.1582e-03 2.1956e+02 1.3111e+01 3.3625e-01 1.6000e+01 #> 5 1.4108e-02 1.0503e+01 7.9526e-04 2.1093e+02 1.2555e+01 2.9865e-02 3.2000e+01 #> 6 6.8579e-03 1.0170e+01 2.0129e-04 2.1102e+02 9.9169e+00 3.8931e-01 6.4000e+01 #> 7 3.5937e-03 1.0490e+01 5.4733e-05 2.1709e+02 1.2669e+01 3.6073e-01 1.2800e+02 #> 8 1.7843e-03 1.0185e+01 1.3757e-05 2.1383e+02 9.7348e+00 3.4885e-01 2.5600e+02 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.965258 (exponent for MLMC weak convergence) #> beta = 1.924650 (exponent for MLMC variance) #> gamma = 1.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0250 1.0446e+01 5.278e+05 2.881e+07 54.59 468086 9101 3436 1207 505 183 65 #> 0.1000 1.0334e+01 3.549e+04 4.684e+05 13.20 28562 1000 1000 76 20 #>"},{"path":"https://mlmc.louisaslett.com/reference/opre_l.html","id":null,"dir":"Reference","previous_headings":"","what":"Financial options using an Euler-Maruyama discretisation — opre_l","title":"Financial options using an Euler-Maruyama discretisation — opre_l","text":"Financial options based scalar geometric Brownian motion Heston models, similar Mike Giles' original 2008 Operations Research paper, Giles (2008), using Euler-Maruyama discretisation","code":""},{"path":"https://mlmc.louisaslett.com/reference/opre_l.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Financial options using an Euler-Maruyama discretisation — opre_l","text":"","code":"opre_l(l, N, option)"},{"path":"https://mlmc.louisaslett.com/reference/opre_l.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Financial options using an Euler-Maruyama discretisation — opre_l","text":"l level simulated. N number samples computed. option option type, 1 5. options : 1 = European call; 2 = Asian call; 3 = lookback call; 4 = digital call; 5 = Heston model.","code":""},{"path":"https://mlmc.louisaslett.com/reference/opre_l.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Financial options using an Euler-Maruyama discretisation — opre_l","text":"named list containing: sums vector length six \\(\\left(\\sum Y_i, \\sum Y_i^2, \\sum Y_i^3, \\sum Y_i^4, \\sum X_i, \\sum X_i^2\\right)\\) \\(Y_i\\) iid simulations expectation \\(E[P_0]\\) \\(l=0\\) expectation \\(E[P_l-P_{l-1}]\\) \\(l>0\\), \\(X_i\\) iid simulations expectation \\(E[P_l]\\). Note first two components used main mlmc() driver, full vector used mlmc.test() convergence tests etc; cost scalar total cost paths simulated, computed \\(N \\times 4^l\\) level \\(l\\).","code":""},{"path":"https://mlmc.louisaslett.com/reference/opre_l.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Financial options using an Euler-Maruyama discretisation — opre_l","text":"function based GPL-2 'Matlab' code Mike Giles.","code":""},{"path":"https://mlmc.louisaslett.com/reference/opre_l.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Financial options using an Euler-Maruyama discretisation — opre_l","text":"Giles, M.B. (2008) 'Multilevel Monte Carlo Path Simulation', Operations Research, 56(3), pp. 607–617. Available : doi:10.1287/opre.1070.0496 .","code":""},{"path":"https://mlmc.louisaslett.com/reference/opre_l.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Financial options using an Euler-Maruyama discretisation — opre_l","text":"Louis Aslett Mike Giles Tigran Nagapetyan ","code":""},{"path":"https://mlmc.louisaslett.com/reference/opre_l.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Financial options using an Euler-Maruyama discretisation — opre_l","text":"","code":"# \\donttest{ # These are similar to the MLMC tests for the original # 2008 Operations Research paper, using an Euler-Maruyama # discretisation with 4^l timesteps on level l. # # The differences are: # -- the plots do not have the extrapolation results # -- two plots are log_2 rather than log_4 # -- the new MLMC driver is a little different # -- switch to X_0=100 instead of X_0=1 # # Note the following takes quite a while to run, for a toy example see after # this block. N0 <- 1000 # initial samples on coarse levels Lmin <- 2 # minimum refinement level Lmax <- 6 # maximum refinement level test.res <- list() for(option in 1:5) { if(option == 1) { cat(\"\\n ---- Computing European call ---- \\n\") N <- 1000000 # samples for convergence tests L <- 5 # levels for convergence tests Eps <- c(0.005, 0.01, 0.02, 0.05, 0.1) } else if(option == 2) { cat(\"\\n ---- Computing Asian call ---- \\n\") N <- 1000000 # samples for convergence tests L <- 5 # levels for convergence tests Eps <- c(0.005, 0.01, 0.02, 0.05, 0.1) } else if(option == 3) { cat(\"\\n ---- Computing lookback call ---- \\n\") N <- 1000000 # samples for convergence tests L <- 5 # levels for convergence tests Eps <- c(0.01, 0.02, 0.05, 0.1, 0.2) } else if(option == 4) { cat(\"\\n ---- Computing digital call ---- \\n\") N <- 4000000 # samples for convergence tests L <- 5 # levels for convergence tests Eps <- c(0.02, 0.05, 0.1, 0.2, 0.5) } else if(option == 5) { cat(\"\\n ---- Computing Heston model ---- \\n\") N <- 2000000 # samples for convergence tests L <- 5 # levels for convergence tests Eps <- c(0.005, 0.01, 0.02, 0.05, 0.1) } test.res[[option]] <- mlmc.test(opre_l, N, L, N0, Eps, Lmin, Lmax, option = option) # print exact analytic value, based on S0=K T <- 1 r <- 0.05 sig <- 0.2 K <- 100 k <- 0.5*sig^2/r; d1 <- (r+0.5*sig^2)*T / (sig*sqrt(T)) d2 <- (r-0.5*sig^2)*T / (sig*sqrt(T)) if(option == 1) { val <- K*( pnorm(d1) - exp(-r*T)*pnorm(d2) ) } else if(option == 2) { val <- NA } else if(option == 3) { val <- K*( pnorm(d1) - pnorm(-d1)*k - exp(-r*T)*(pnorm(d2) - pnorm(d2)*k) ) } else if(option == 4) { val <- K*exp(-r*T)*pnorm(d2) } else if(option == 5) { val <- NA } if(is.na(val)) { cat(sprintf(\"\\n Exact value unknown, MLMC value: %f \\n\", test.res[[option]]$P[1])) } else { cat(sprintf(\"\\n Exact value: %f, MLMC value: %f \\n\", val, test.res[[option]]$P[1])) } # plot results plot(test.res[[option]]) } #> #> ---- Computing European call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 1e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0225e+01 1.0225e+01 1.6140e+02 1.6140e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.1300e-01 1.0416e+01 4.4386e+00 2.0116e+02 2.0359e+01 2.4583e-01 4.0000e+00 #> 2 3.0142e-02 1.0443e+01 1.0682e+00 2.1343e+02 1.2848e+01 3.8346e-02 1.6000e+01 #> 3 5.6439e-03 1.0436e+01 2.7167e-01 2.1522e+02 7.6217e+00 1.4220e-01 6.4000e+01 #> 4 1.0348e-03 1.0459e+01 6.9123e-02 2.1671e+02 6.3099e+00 2.5154e-01 2.5600e+02 #> 5 5.4423e-04 1.0441e+01 1.7231e-02 2.1604e+02 5.9106e+00 2.1656e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.208927 (exponent for MLMC weak convergence) #> beta = 1.996768 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0444e+01 4.649e+07 2.959e+09 63.64 19982970 1663468 409221 102841 26282 #> 0.0100 1.0438e+01 8.422e+06 1.837e+08 21.81 4251529 354397 85970 21517 #> 0.0200 1.0456e+01 2.123e+06 4.591e+07 21.63 1067991 87921 21861 5521 #> 0.0500 1.0396e+01 2.416e+05 1.821e+06 7.54 141217 13256 2963 #> 0.1000 1.0445e+01 6.352e+04 4.553e+05 7.17 35109 3102 1000 #> #> #> Exact value: 10.450584, MLMC value: 10.444362 #> #> ---- Computing Asian call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 1e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 5.1068e+00 5.1068e+00 4.0327e+01 4.0327e+01 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 5.9794e-01 5.7065e+00 1.5850e+01 5.7667e+01 4.8820e+00 3.2165e-02 4.0000e+00 #> 2 4.9532e-02 5.7497e+00 1.4223e+00 6.2082e+01 5.9670e+00 1.2643e-01 1.6000e+01 #> 3 5.0397e-03 5.7722e+00 1.5257e-01 6.3261e+01 6.1551e+00 3.5811e-01 6.4000e+01 #> 4 1.1640e-03 5.7537e+00 2.4858e-02 6.3307e+01 5.9880e+00 4.0786e-01 2.5600e+02 #> 5 2.1230e-04 5.7639e+00 5.3853e-03 6.3626e+01 5.6941e+00 2.0749e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.833053 (exponent for MLMC weak convergence) #> beta = 2.888474 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 5.7646e+00 2.729e+07 2.159e+08 7.91 7655860 2406902 360400 66221 #> 0.0100 5.7467e+00 6.825e+06 5.398e+07 7.91 1912554 602189 90182 16571 #> 0.0200 5.7810e+00 1.709e+06 1.350e+07 7.90 479306 149650 22718 4175 #> 0.0500 5.7230e+00 1.956e+05 5.298e+05 2.71 65724 20500 2990 #> 0.1000 5.6500e+00 5.200e+04 1.324e+05 2.55 16025 4993 1000 #> #> #> Exact value unknown, MLMC value: 5.764555 #> #> ---- Computing lookback call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 1e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 2.0655e+01 2.0655e+01 1.7531e+02 1.7531e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 -2.5126e+00 1.8139e+01 1.3973e+01 1.9931e+02 4.5082e+00 3.3656e-02 4.0000e+00 #> 2 -6.8917e-01 1.7464e+01 4.8781e+00 2.0900e+02 3.9911e+00 1.4922e-01 1.6000e+01 #> 3 -1.7874e-01 1.7256e+01 1.4370e+00 2.1157e+02 3.7921e+00 3.2822e-01 6.4000e+01 #> 4 -4.4906e-02 1.7241e+01 3.8719e-01 2.1320e+02 3.7138e+00 3.4186e-01 2.5600e+02 #> 5 -1.1632e-02 1.7229e+01 1.0042e-01 2.1343e+02 3.6632e+00 1.2626e-03 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 1.944965 (exponent for MLMC weak convergence) #> beta = 1.789603 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0100 1.7222e+01 4.765e+07 2.914e+09 61.15 10554014 1487827 440827 119886 30901 8310 #> 0.0200 1.7237e+01 1.194e+07 7.285e+08 61.00 2643654 372982 110106 29862 7780 2092 #> 0.0500 1.7165e+01 1.892e+06 1.166e+08 61.61 420456 58811 17380 4908 1212 326 #> 0.1000 1.6962e+01 4.433e+05 2.914e+07 65.74 101158 14254 4198 1125 258 78 #> 0.2000 1.7408e+01 5.640e+04 4.513e+05 8.00 17345 2453 1000 207 #> #> #> Exact value: 17.216802, MLMC value: 17.222393 #> #> ---- Computing digital call ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 4e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 5.6943e+01 5.6943e+01 2.1741e+03 2.1741e+03 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 -2.7954e+00 5.4125e+01 2.5809e+02 2.2190e+03 3.2059e+01 1.3674e-01 4.0000e+00 #> 2 -6.9818e-01 5.3471e+01 1.6582e+02 2.2272e+03 5.4104e+01 2.7114e-01 1.6000e+01 #> 3 -1.7177e-01 5.3314e+01 8.5629e+01 2.2290e+03 1.0556e+02 9.8189e-02 6.4000e+01 #> 4 -4.2758e-02 5.3243e+01 4.3557e+01 2.2298e+03 2.0771e+02 1.8516e-01 2.5600e+02 #> 5 -9.1318e-03 5.3243e+01 2.1856e+01 2.2298e+03 4.1399e+02 5.7742e-02 1.0240e+03 #> #> WARNING: kurtosis on finest level = 413.989826 #> indicates MLMC correction dominated by a few rare paths; #> for information on the connection to variance of sample variances, #> see http://mathworld.wolfram.com/SampleVarianceDistribution.html #> #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.054519 (exponent for MLMC weak convergence) #> beta = 0.905215 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0200 5.3238e+01 7.198e+08 7.611e+09 10.57 72212192 12465191 4976067 1809513 638892 233175 #> 0.0500 5.3243e+01 5.106e+07 3.044e+08 5.96 7693372 1323219 532130 187664 68565 #> 0.1000 5.3226e+01 1.302e+07 7.611e+07 5.84 1942663 334172 130755 47694 17964 #> 0.2000 5.3301e+01 1.442e+06 4.755e+06 3.30 323329 55831 22220 8442 #> 0.5000 5.3518e+01 2.349e+05 7.608e+05 3.24 52202 8958 3456 1431 #> #> #> Exact value: 53.232482, MLMC value: 53.237966 #> #> ---- Computing Heston model ---- #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 2e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0217e+01 1.0217e+01 1.6116e+02 1.6116e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.1361e-01 1.0424e+01 3.5554e+00 1.9063e+02 1.5022e+01 1.1127e-01 4.0000e+00 #> 2 3.2716e-02 1.0424e+01 3.7040e+00 1.9165e+02 7.4001e+00 5.1720e-01 1.6000e+01 #> 3 5.2579e-03 1.0442e+01 1.7502e+00 1.9157e+02 6.1162e+00 2.0107e-01 6.4000e+01 #> 4 1.3222e-03 1.0449e+01 5.1204e-01 1.9160e+02 5.5678e+00 9.7420e-02 2.5600e+02 #> 5 1.2331e-04 1.0477e+01 1.3359e-01 1.9208e+02 5.4375e+00 4.6277e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.614583 (exponent for MLMC weak convergence) #> beta = 1.232292 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0456e+01 6.441e+07 6.539e+08 10.15 23522225 1747622 890878 306918 #> 0.0100 1.0453e+01 1.606e+07 1.635e+08 10.18 5872993 434922 222298 76339 #> 0.0200 1.0466e+01 1.956e+06 1.022e+07 5.23 1024914 76452 39061 #> 0.0500 1.0467e+01 3.128e+05 1.635e+06 5.23 163241 12489 6228 #> 0.1000 1.0485e+01 8.505e+04 4.088e+05 4.81 44380 3584 1646 #> #> #> Exact value unknown, MLMC value: 10.456461 # } # The level sampler can be called directly to retrieve the relevant level sums: opre_l(l = 7, N = 10, option = 1) #> $sums #> [1] 2.790908e-01 1.932997e-02 1.494244e-03 1.232423e-04 1.698023e+02 #> [6] 4.757903e+03 #> #> $cost #> [1] 163840 #>"},{"path":"https://mlmc.louisaslett.com/reference/plot.mlmc.test.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot an mlmc.test object — plot.mlmc.test","title":"Plot an mlmc.test object — plot.mlmc.test","text":"Produces diagnostic plots result mlmc.test function call.","code":""},{"path":"https://mlmc.louisaslett.com/reference/plot.mlmc.test.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot an mlmc.test object — plot.mlmc.test","text":"","code":"# S3 method for class 'mlmc.test' plot(x, which = \"all\", cols = NA, ...)"},{"path":"https://mlmc.louisaslett.com/reference/plot.mlmc.test.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot an mlmc.test object — plot.mlmc.test","text":"x mlmc.test object produced call mlmc.test function. vector strings specifying plots produce, \"\" diagnostic plots options : \"var\" = \\(\\log_2\\) variance level; \"mean\" = \\(\\log_2\\) absolute value mean level; \"consis\" = consistency level; \"kurt\" = kurtosis level; \"Nl\" = \\(\\log_2\\) number samples level; \"cost\" = \\(\\log_{10}\\) cost \\(\\log_{10}\\) epsilon (accuracy). cols number columns across plot override default value. ... additional arguments passed plotting functions.","code":""},{"path":"https://mlmc.louisaslett.com/reference/plot.mlmc.test.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot an mlmc.test object — plot.mlmc.test","text":"return value, called side effects.","code":""},{"path":"https://mlmc.louisaslett.com/reference/plot.mlmc.test.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot an mlmc.test object — plot.mlmc.test","text":"plots produced relatively self-explanatory. However, consistency kurtosis plots particular may require background. highly recommended refer Section 3.3 Giles (2015), rationale diagnostic plots addressed full detail.","code":""},{"path":"https://mlmc.louisaslett.com/reference/plot.mlmc.test.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Plot an mlmc.test object — plot.mlmc.test","text":"Giles, M.B. (2015) 'Multilevel Monte Carlo methods', Acta Numerica, 24, pp. 259–328. Available : doi:10.1017/S096249291500001X .","code":""},{"path":"https://mlmc.louisaslett.com/reference/plot.mlmc.test.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Plot an mlmc.test object — plot.mlmc.test","text":"Louis Aslett ","code":""},{"path":"https://mlmc.louisaslett.com/reference/plot.mlmc.test.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot an mlmc.test object — plot.mlmc.test","text":"","code":"# \\donttest{ tst <- mlmc.test(opre_l, N = 2000000, L = 5, N0 = 1000, eps.v = c(0.005, 0.01, 0.02, 0.05, 0.1), Lmin = 2, Lmax = 6, option = 1) #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 2e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0199e+01 1.0199e+01 1.6089e+02 1.6089e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.0746e-01 1.0403e+01 4.4448e+00 2.0078e+02 1.9899e+01 5.5811e-02 4.0000e+00 #> 2 2.9638e-02 1.0433e+01 1.0627e+00 2.1254e+02 1.2099e+01 7.8670e-03 1.6000e+01 #> 3 5.5601e-03 1.0424e+01 2.7202e-01 2.1487e+02 7.4630e+00 2.2499e-01 6.4000e+01 #> 4 1.2735e-03 1.0434e+01 6.8866e-02 2.1629e+02 6.2753e+00 1.3990e-01 2.5600e+02 #> 5 4.3712e-04 1.0471e+01 1.7275e-02 2.1673e+02 5.9212e+00 5.7427e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.232166 (exponent for MLMC weak convergence) #> beta = 1.996237 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0451e+01 4.621e+07 2.953e+09 63.90 19931030 1650675 405130 102836 25843 #> 0.0100 1.0447e+01 8.422e+06 1.834e+08 21.77 4252711 351640 86157 21635 #> 0.0200 1.0431e+01 2.130e+06 4.584e+07 21.52 1068631 89774 21647 5566 #> 0.0500 1.0459e+01 2.405e+05 1.814e+06 7.54 142383 12790 2937 #> 0.1000 1.0505e+01 6.535e+04 4.534e+05 6.94 36775 3144 1000 #> tst #> #> ********************************************************** #> *** Convergence tests, kurtosis, telescoping sum check *** #> *** using N = 2e+06 samples *** #> ********************************************************** #> #> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost #> --------------------------------------------------------------------------------------- #> 0 1.0199e+01 1.0199e+01 1.6089e+02 1.6089e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.0746e-01 1.0403e+01 4.4448e+00 2.0078e+02 1.9899e+01 5.5811e-02 4.0000e+00 #> 2 2.9638e-02 1.0433e+01 1.0627e+00 2.1254e+02 1.2099e+01 7.8670e-03 1.6000e+01 #> 3 5.5601e-03 1.0424e+01 2.7202e-01 2.1487e+02 7.4630e+00 2.2499e-01 6.4000e+01 #> 4 1.2735e-03 1.0434e+01 6.8866e-02 2.1629e+02 6.2753e+00 1.3990e-01 2.5600e+02 #> 5 4.3712e-04 1.0471e+01 1.7275e-02 2.1673e+02 5.9212e+00 5.7427e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.232166 (exponent for MLMC weak convergence) #> beta = 1.996237 (exponent for MLMC variance) #> gamma = 2.000000 (exponent for MLMC cost) #> #> ***************************** #> *** MLMC complexity tests *** #> ***************************** #> #> eps value mlmc_cost std_cost savings N_l #> ----------------------------------------------------------- #> 0.0050 1.0451e+01 4.621e+07 2.953e+09 63.90 19931030 1650675 405130 102836 25843 #> 0.0100 1.0447e+01 8.422e+06 1.834e+08 21.77 4252711 351640 86157 21635 #> 0.0200 1.0431e+01 2.130e+06 4.584e+07 21.52 1068631 89774 21647 5566 #> 0.0500 1.0459e+01 2.405e+05 1.814e+06 7.54 142383 12790 2937 #> 0.1000 1.0505e+01 6.535e+04 4.534e+05 6.94 36775 3144 1000 #> plot(tst) # }"},{"path":"https://mlmc.louisaslett.com/news/index.html","id":"mlmc-211","dir":"Changelog","previous_headings":"","what":"mlmc 2.1.1","title":"mlmc 2.1.1","text":"Bug fix parallel processing main driver mlmc.test (thanks Qian Xin, University Bristol, bug report). time, improve method splitting simulations parallel main mlmc driver, work evenly distributed keep cores busy.","code":""},{"path":"https://mlmc.louisaslett.com/news/index.html","id":"mlmc-210","dir":"Changelog","previous_headings":"","what":"mlmc 2.1.0","title":"mlmc 2.1.0","text":"CRAN release: 2024-11-08 Add parameter value checks mlmc.test. Allow user specify alpha, beta, gamma mlmc.test, rather forcing estimation linear regression. Note departure original Matlab code, left unspecified results Matlab reproduced. Improve specificity argument documentation mlmc.test.","code":""},{"path":"https://mlmc.louisaslett.com/news/index.html","id":"mlmc-202","dir":"Changelog","previous_headings":"","what":"mlmc 2.0.2","title":"mlmc 2.0.2","text":"CRAN release: 2024-09-04 Package removed CRAN didn’t notice old Oxford email address wasn’t forwarding longer. order comply CRAN changes, C++ routines now registered maintainer info updated Durham email. User level sampling functions must now also return total cost samples simulated level. Therefore user level sampler functions must return list sums cost element. gamma argument longer required, since used automatic cost computation, can estimated alpha beta. mlmc.test() longer takes M, level refinement factor, since used calculate cost N*M^l. Per comment, user now defines cost completely via return level sampler function. Along lines, mlmc.test() now uses user returned cost places: previously CPU time measured cost convergence tests section, whilst MLMC complexity tests previously forced costs N*M^l. () old bugs squashed Euler-Maruyama discretisation level sampler, opre_l() affected lookback call Heston model options. managed get hold Matlab license, now confirmed examples docs return (within sampling variability) results Euler-Maruyama Milstein discretisation example level sampler functions. now hex sticker! hopefully fairly self explanatory: many fast simulations done low levels (lots dice, hare running bottom stairs); fewer simulations done higher levels (fewer dice go step, tortoise fewest dice top step)! now documentation website https://mlmc.louisaslett.com/","code":""},{"path":"https://mlmc.louisaslett.com/news/index.html","id":"mlmc-100","dir":"Changelog","previous_headings":"","what":"mlmc 1.0.0","title":"mlmc 1.0.0","text":"CRAN release: 2016-04-24 Initial CRAN submission.","code":""}]