if (FALSE) { # \dontrun{
+
Details
Most of the plots produced are relatively self-explanatory.
@@ -101,15 +105,86 @@
Author<
Examples
-
if (FALSE) { # \dontrun{
+ # \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.0202e+01 1.0202e+01 1.6129e+02 1.6129e+02 0.0000e+00 0.0000e+00 1.0000e+00
+#> 1 2.1014e-01 1.0417e+01 4.4552e+00 2.0129e+02 1.9673e+01 8.0284e-02 4.0000e+00
+#> 2 2.8422e-02 1.0428e+01 1.0613e+00 2.1264e+02 1.1720e+01 2.7044e-01 1.6000e+01
+#> 3 5.9586e-03 1.0423e+01 2.7188e-01 2.1507e+02 7.5254e+00 1.7456e-01 6.4000e+01
+#> 4 1.4902e-03 1.0437e+01 6.8853e-02 2.1588e+02 6.2866e+00 2.0275e-01 2.5600e+02
+#> 5 3.2438e-04 1.0467e+01 1.7287e-02 2.1681e+02 5.9238e+00 4.6968e-01 1.0240e+03
+#>
+#> ******************************************************
+#> *** Linear regression estimates of MLMC parameters ***
+#> ******************************************************
+#>
+#> alpha = 2.293234 (exponent for MLMC weak convergence)
+#> beta = 1.996557 (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.0445e+01 3.387e+07 7.341e+08 21.67 17049661 1419280 346601 87520
+#> 0.0100 1.0451e+01 8.457e+06 1.835e+08 21.70 4262024 352482 86700 21841
+#> 0.0200 1.0462e+01 2.141e+06 4.588e+07 21.43 1072807 89338 22072 5588
+#> 0.0500 1.0496e+01 2.471e+05 1.815e+06 7.34 149418 12491 2983
+#> 0.1000 1.0467e+01 6.762e+04 4.536e+05 6.71 38372 3313 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.0202e+01 1.0202e+01 1.6129e+02 1.6129e+02 0.0000e+00 0.0000e+00 1.0000e+00
+#> 1 2.1014e-01 1.0417e+01 4.4552e+00 2.0129e+02 1.9673e+01 8.0284e-02 4.0000e+00
+#> 2 2.8422e-02 1.0428e+01 1.0613e+00 2.1264e+02 1.1720e+01 2.7044e-01 1.6000e+01
+#> 3 5.9586e-03 1.0423e+01 2.7188e-01 2.1507e+02 7.5254e+00 1.7456e-01 6.4000e+01
+#> 4 1.4902e-03 1.0437e+01 6.8853e-02 2.1588e+02 6.2866e+00 2.0275e-01 2.5600e+02
+#> 5 3.2438e-04 1.0467e+01 1.7287e-02 2.1681e+02 5.9238e+00 4.6968e-01 1.0240e+03
+#>
+#> ******************************************************
+#> *** Linear regression estimates of MLMC parameters ***
+#> ******************************************************
+#>
+#> alpha = 2.293234 (exponent for MLMC weak convergence)
+#> beta = 1.996557 (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.0445e+01 3.387e+07 7.341e+08 21.67 17049661 1419280 346601 87520
+#> 0.0100 1.0451e+01 8.457e+06 1.835e+08 21.70 4262024 352482 86700 21841
+#> 0.0200 1.0462e+01 2.141e+06 4.588e+07 21.43 1072807 89338 22072 5588
+#> 0.0500 1.0496e+01 2.471e+05 1.815e+06 7.34 149418 12491 2983
+#> 0.1000 1.0467e+01 6.762e+04 4.536e+05 6.71 38372 3313 1000
+#>
plot(tst)
-} # }
+
+# }
diff --git a/search.json b/search.json
index b52e0bc..4bb39a1 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.0.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.0.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, nagapetyan@stats.ox.ac.uk vollmer@stats.ox.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 release directly CRAN. can install latest binary r-universe:","code":"install.packages(\"mlmc\") install.packages(\"mlmc\", repos = c(\"https://louisaslett.r-universe.dev\", \"https://cloud.r-project.org\"))"},{"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. 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}, 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":"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":"if (FALSE) { # \\dontrun{ # 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 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]]) } } # } # The level sampler can be called directly to retrieve the relevant level sums: mcqmc06_l(l = 7, N = 10, option = 1) #> $sums #> [1] 4.065939e-02 4.561184e-04 5.165569e-06 6.039214e-08 9.787067e+01 #> [6] 2.147454e+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 two \\(\\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\\). 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":"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.44813 #> #> $Nl #> [1] 4294178 357038 106626 22315 #> #> $Cl #> [1] 1 4 16 64 #> mlmc(2, 10, 1000, 0.01, mcqmc06_l, option = 1) #> $P #> [1] 10.43656 #> #> $Nl #> [1] 3018378 56809 28405 8180 3002 1100 378 146 #> #> $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, 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 two \\(\\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\\). 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 tests L number levels use tests N0 initial number samples used first 3 levels subsequent levels automatically added. Must \\(> 0\\). eps.v vector one target accuracies tests. Must \\(> 0\\). Lmin minimum level refinement. Must \\(\\ge 2\\). Lmax maximum level refinement. Must \\(\\ge\\) Lmin. 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":"if (FALSE) { # \\dontrun{ # 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) tst 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) tst 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 9.9864e+00 9.9864e+00 1.5806e+02 1.5806e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.3616e-01 1.0528e+01 4.6195e+00 2.0513e+02 2.0180e+01 3.5003e-01 4.0000e+00 #> 2 3.6916e-02 1.0709e+01 1.1293e+00 2.2145e+02 1.3114e+01 1.5936e-01 1.6000e+01 #> 3 3.7534e-03 1.0384e+01 2.6563e-01 2.1298e+02 6.6822e+00 3.6542e-01 6.4000e+01 #> 4 2.3320e-03 1.0483e+01 6.7543e-02 2.1957e+02 6.4185e+00 1.0816e-01 2.5600e+02 #> 5 1.5741e-03 1.0830e+01 1.8175e-02 2.2166e+02 5.8218e+00 3.8607e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 1.844283 (exponent for MLMC weak convergence) #> beta = 2.004277 (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.0470e+01 1.370e+06 2.908e+07 21.22 685621 57426 13880 3639 #> 0.1000 1.0323e+01 6.383e+04 4.724e+05 7.40 35781 3013 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.9254e+00 9.9254e+00 1.9093e+02 1.9093e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 1.8237e-01 1.0161e+01 1.6474e-01 2.0577e+02 1.5619e+02 6.1665e-02 2.0000e+00 #> 2 1.0610e-01 1.0567e+01 4.3677e-02 2.1657e+02 2.4251e+01 3.4217e-01 4.0000e+00 #> 3 5.3915e-02 1.0397e+01 1.1391e-02 2.1350e+02 1.6232e+01 2.5413e-01 8.0000e+00 #> 4 2.8379e-02 1.0610e+01 3.1579e-03 2.2062e+02 1.6977e+01 2.0880e-01 1.6000e+01 #> 5 1.4092e-02 1.0527e+01 8.3114e-04 2.1503e+02 1.3656e+01 1.0984e-01 3.2000e+01 #> 6 6.9390e-03 1.0364e+01 2.0637e-04 2.1144e+02 1.0092e+01 1.9322e-01 6.4000e+01 #> 7 3.5004e-03 1.0411e+01 5.1394e-05 2.1552e+02 1.0496e+01 4.9106e-02 1.2800e+02 #> 8 1.7754e-03 1.0504e+01 1.3201e-05 2.1573e+02 8.9490e+00 1.0384e-01 2.5600e+02 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.967513 (exponent for MLMC weak convergence) #> beta = 1.942754 (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.0462e+01 5.305e+05 2.887e+07 54.42 471243 9357 3473 1309 468 158 57 #> 0.1000 1.0562e+01 3.641e+04 4.707e+05 12.93 29249 1000 1000 81 32 #>"},{"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":"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":"if (FALSE) { # \\dontrun{ # 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 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]]) } } # } # The level sampler can be called directly to retrieve the relevant level sums: opre_l(l = 7, N = 10, option = 1) #> $sums #> [1] 1.064477e-02 2.275113e-02 -6.541730e-04 1.403334e-04 1.485436e+02 #> [6] 4.556201e+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":"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":"if (FALSE) { # \\dontrun{ 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) tst plot(tst) } # }"},{"path":"https://mlmc.louisaslett.com/news/index.html","id":"mlmc-201","dir":"Changelog","previous_headings":"","what":"mlmc 2.0.1","title":"mlmc 2.0.1","text":"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.0.2, 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.0.2, 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, nagapetyan@stats.ox.ac.uk vollmer@stats.ox.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 release directly CRAN. can install latest binary r-universe:","code":"install.packages(\"mlmc\") install.packages(\"mlmc\", repos = c(\"https://louisaslett.r-universe.dev\", \"https://cloud.r-project.org\"))"},{"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. 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}, 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.0029e+01 1.0029e+01 1.9722e+02 1.9722e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 1.8394e-01 1.0290e+01 1.4600e-01 2.0587e+02 3.9810e+01 1.2720e-01 2.0000e+00 #> 2 1.0333e-01 1.0388e+01 4.2175e-02 2.1234e+02 3.3379e+01 8.3887e-03 4.0000e+00 #> 3 5.4322e-02 1.0369e+01 1.1838e-02 2.1705e+02 1.6591e+01 1.1764e-01 8.0000e+00 #> 4 2.8126e-02 1.0552e+01 3.2235e-03 2.1932e+02 1.3227e+01 2.4578e-01 1.6000e+01 #> 5 1.3857e-02 1.0318e+01 8.3669e-04 2.1392e+02 1.3113e+01 3.9635e-01 3.2000e+01 #> 6 7.1684e-03 1.0487e+01 2.0915e-04 2.1799e+02 1.1029e+01 2.5931e-01 6.4000e+01 #> 7 3.5655e-03 1.0418e+01 5.1754e-05 2.1059e+02 9.7300e+00 1.1593e-01 1.2800e+02 #> 8 1.7807e-03 1.0446e+01 1.3881e-05 2.2270e+02 1.3242e+01 4.0847e-02 2.5600e+02 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.963172 (exponent for MLMC weak convergence) #> beta = 1.920125 (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.0456e+01 1.357e+07 3.041e+09 224.13 11906524 232615 91191 33305 12323 4397 1541 574 209 #> 0.0100 1.0448e+01 3.358e+06 3.594e+08 107.02 2957299 58040 24187 8085 2986 1072 388 130 #> 0.0200 1.0474e+01 8.373e+05 4.650e+07 55.54 739789 15333 5622 1982 806 291 98 #> 0.0500 1.0455e+01 1.324e+05 3.651e+06 27.57 117749 2356 823 375 135 47 #> 0.1000 1.0323e+01 3.216e+04 4.679e+05 14.55 28570 569 200 104 51 #> #> #> Exact value: 10.450584, MLMC value: 10.456468 #> #> ---- 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.5951e+00 5.5951e+00 6.0102e+01 6.0102e+01 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 4.1848e-02 5.6599e+00 2.5574e-01 6.1727e+01 1.6183e+01 6.7128e-02 2.0000e+00 #> 2 4.1015e-02 5.6638e+00 3.8719e-02 6.1679e+01 1.3926e+01 1.0993e-01 4.0000e+00 #> 3 2.7105e-02 5.8340e+00 6.1034e-03 6.3818e+01 8.0283e+00 4.2362e-01 8.0000e+00 #> 4 1.5105e-02 5.7268e+00 1.2618e-03 6.3991e+01 8.9021e+00 3.5953e-01 1.6000e+01 #> 5 7.5520e-03 5.7032e+00 2.7444e-04 6.3187e+01 8.1746e+00 9.2026e-02 3.2000e+01 #> 6 3.9493e-03 5.7242e+00 6.3849e-05 6.2996e+01 7.4206e+00 5.0343e-02 6.4000e+01 #> 7 1.9923e-03 5.7760e+00 1.5791e-05 6.3790e+01 8.4057e+00 1.4766e-01 1.2800e+02 #> 8 9.9651e-04 5.7188e+00 3.7720e-06 6.3177e+01 7.4076e+00 1.7234e-01 2.5600e+02 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.820236 (exponent for MLMC weak convergence) #> beta = 2.268800 (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.7605e+00 4.725e+06 8.626e+08 182.56 3873079 175297 48809 15168 4535 1444 485 166 53 #> 0.0100 5.7535e+00 1.182e+06 1.089e+08 92.10 968052 44224 12467 3893 1173 374 132 42 #> 0.0200 5.7370e+00 2.894e+05 1.344e+07 46.44 239448 10974 2833 894 284 95 30 #> 0.0500 5.7458e+00 4.528e+04 5.461e+05 12.06 37958 1862 436 140 46 #> 0.1000 5.6778e+00 1.039e+04 3.290e+04 3.17 8849 371 200 #> #> #> Exact value unknown, MLMC value: 5.760501 #> #> ---- 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.7511e+01 1.7511e+01 1.8272e+02 1.8272e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 -1.1451e-01 1.7641e+01 1.4254e+00 1.9415e+02 1.0742e+01 4.0186e-01 2.0000e+00 #> 2 -1.3721e-01 1.7368e+01 4.9198e-01 2.0461e+02 8.3115e+00 2.2081e-01 4.0000e+00 #> 3 -9.4454e-02 1.7255e+01 1.4952e-01 2.1249e+02 8.0617e+00 3.0306e-02 8.0000e+00 #> 4 -5.4218e-02 1.7330e+01 4.0505e-02 2.1245e+02 7.6582e+00 2.0807e-01 1.6000e+01 #> 5 -2.8215e-02 1.7190e+01 1.0298e-02 2.1322e+02 7.4335e+00 1.8081e-01 3.2000e+01 #> 6 -1.4180e-02 1.7217e+01 2.6559e-03 2.1334e+02 9.3109e+00 6.6450e-02 6.4000e+01 #> 7 -7.2142e-03 1.7281e+01 6.7944e-04 2.1261e+02 7.8428e+00 1.1579e-01 1.2800e+02 #> 8 -3.5886e-03 1.7277e+01 1.6721e-04 2.1483e+02 7.2920e+00 1.4140e-03 2.5600e+02 #> 9 -1.7421e-03 1.7406e+01 4.1219e-05 2.1655e+02 7.2133e+00 2.1006e-01 5.1200e+02 #> 10 -8.5668e-04 1.7203e+01 1.0125e-05 2.1479e+02 7.5526e+00 3.2429e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.854377 (exponent for MLMC weak convergence) #> beta = 1.923630 (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.198e+07 1.173e+10 533.68 14705013 903557 378904 146464 53597 19602 6853 2548 928 335 119 #> 0.0100 1.7220e+01 5.439e+06 1.478e+09 271.80 3656467 225494 93830 36431 13514 4838 1751 625 229 84 #> 0.0200 1.7217e+01 1.333e+06 1.833e+08 137.50 903171 55947 23402 9207 3330 1206 429 135 56 #> 0.0500 1.7195e+01 2.276e+05 1.451e+07 63.77 158622 9132 3715 1505 513 218 79 28 #> 0.1000 1.7285e+01 4.837e+04 9.097e+05 18.81 34322 2144 884 354 126 43 #> #> #> Exact value: 17.216802, MLMC value: 17.220294 #> #> ---- 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.7040e+00 5.4204e+01 2.0283e-01 7.2524e+02 1.1215e+01 2.3129e-01 2.0000e+00 #> 2 -7.1971e-01 5.3474e+01 1.9122e+00 1.1903e+03 1.8316e+01 2.4219e-02 4.0000e+00 #> 3 -2.0226e-01 5.3362e+01 1.2522e+00 1.5093e+03 2.2352e+01 1.8000e-01 8.0000e+00 #> 4 -6.1953e-02 5.3186e+01 5.4529e-01 1.7271e+03 3.2836e+01 2.0907e-01 1.6000e+01 #> 5 -2.1556e-02 5.3342e+01 2.1123e-01 1.8701e+03 4.3469e+01 3.1090e-01 3.2000e+01 #> 6 -7.6433e-03 5.3245e+01 7.9410e-02 1.9777e+03 5.9358e+01 1.5181e-01 6.4000e+01 #> 7 -3.5706e-03 5.3145e+01 2.8310e-02 2.0528e+03 8.5312e+01 1.5978e-01 1.2800e+02 #> 8 -2.1199e-03 5.3293e+01 1.0033e-02 2.1033e+03 1.3585e+02 2.4542e-01 2.5600e+02 #> #> WARNING: kurtosis on finest level = 135.851963 #> 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.502312 (exponent for MLMC weak convergence) #> beta = 0.881623 (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.3252e+01 2.929e+06 1.688e+09 576.20 200 62778 136754 79398 36565 16168 8103 #> 0.0200 5.3233e+01 7.604e+05 4.219e+08 554.87 200 15902 34931 20474 9468 4287 2128 #> 0.0500 5.3287e+01 8.405e+04 3.192e+07 379.75 200 2165 4461 2581 1256 654 #> 0.1000 5.3398e+01 1.850e+04 3.685e+06 199.19 200 477 1192 770 401 #> 0.2000 5.3154e+01 3.136e+03 9.211e+05 293.73 200 200 204 105 55 #> #> #> Exact value: 53.232482, MLMC value: 53.251801 #> #> ---- 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.4474e+00 9.4474e+00 1.8929e+02 1.8929e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 1.5951e-01 9.6066e+00 1.7046e-01 1.9977e+02 6.4497e+01 1.7977e-03 2.0000e+00 #> 2 1.4617e-01 9.7725e+00 1.5850e-01 2.0847e+02 9.9998e+01 1.0141e-01 4.0000e+00 #> 3 9.7979e-02 9.8558e+00 1.5455e-01 2.1263e+02 5.7430e+02 7.3983e-02 8.0000e+00 #> 4 4.6242e-02 9.9139e+00 4.6293e-02 2.1629e+02 1.1486e+03 5.9766e-02 1.6000e+01 #> 5 2.0943e-02 9.8764e+00 1.2250e-02 2.1494e+02 1.2541e+03 2.9562e-01 3.2000e+01 #> 6 9.8981e-03 9.9351e+00 3.0235e-03 2.1906e+02 1.1802e+03 2.4669e-01 6.4000e+01 #> 7 4.9817e-03 9.9004e+00 1.4311e-03 2.1603e+02 5.8747e+03 2.0031e-01 1.2800e+02 #> 8 2.3914e-03 1.0021e+01 5.2788e-04 2.1924e+02 2.1485e+04 5.9808e-01 2.5600e+02 #> #> WARNING: kurtosis on finest level = 21484.500811 #> 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.926866 (exponent for MLMC weak convergence) #> beta = 1.324364 (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.9474e+00 2.058e+07 5.987e+09 290.96 14279726 303808 210948 147438 67635 25971 9121 3809 1625 518 #> 0.0100 9.9457e+00 4.929e+06 7.484e+08 151.83 3502625 74757 52075 36492 14831 5822 2249 998 318 #> 0.0200 9.9472e+00 1.090e+06 9.217e+07 84.57 818077 15653 12652 7844 3382 1089 348 124 #> 0.0500 9.9445e+00 1.856e+05 7.477e+06 40.29 135789 3080 2359 1480 640 205 87 #> 0.1000 9.8066e+00 3.432e+04 4.614e+05 13.45 29190 628 330 171 74 #> #> #> Exact value: 9.949270, MLMC value: 9.947443 # } # The level sampler can be called directly to retrieve the relevant level sums: mcqmc06_l(l = 7, N = 10, option = 1) #> $sums #> [1] 5.965277e-02 1.405983e-03 4.231701e-05 1.389170e-06 1.190440e+02 #> [6] 5.613734e+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.4489 #> #> $Nl #> [1] 4274476 355282 103974 22143 #> #> $Cl #> [1] 1 4 16 64 #> mlmc(2, 10, 1000, 0.01, mcqmc06_l, option = 1) #> $P #> [1] 10.44118 #> #> $Nl #> [1] 3049661 58324 29162 8185 3090 1152 441 163 56 #> #> $Cl #> [1] 1 2 4 8 16 32 64 128 256 #>"},{"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, 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 tests L number levels use tests N0 initial number samples used first 3 levels subsequent levels automatically added. Must \\(> 0\\). eps.v vector one target accuracies tests. Must \\(> 0\\). Lmin minimum level refinement. Must \\(\\ge 2\\). Lmax maximum level refinement. Must \\(\\ge\\) Lmin. 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.0196e+01 1.0196e+01 1.6099e+02 1.6099e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.1057e-01 1.0422e+01 4.4430e+00 2.0126e+02 1.9684e+01 2.6040e-01 4.0000e+00 #> 2 2.8460e-02 1.0435e+01 1.0631e+00 2.1220e+02 1.2163e+01 2.4768e-01 1.6000e+01 #> 3 5.9612e-03 1.0463e+01 2.7336e-01 2.1619e+02 7.5955e+00 3.4400e-01 6.4000e+01 #> 4 1.8455e-03 1.0452e+01 6.8677e-02 2.1701e+02 6.2612e+00 1.9414e-01 2.5600e+02 #> 5 4.9396e-04 1.0456e+01 1.7247e-02 2.1695e+02 5.9175e+00 5.9511e-02 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.141832 (exponent for MLMC weak convergence) #> beta = 1.997038 (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.0455e+01 4.609e+07 2.963e+09 64.29 19907394 1654097 402588 101803 25802 #> 0.0100 1.0456e+01 8.493e+06 1.845e+08 21.72 4271774 355405 86235 22183 #> 0.0200 1.0449e+01 2.120e+06 4.612e+07 21.76 1066677 88207 21489 5568 #> 0.0500 1.0486e+01 2.395e+05 1.811e+06 7.56 143709 12008 2983 #> 0.1000 1.0371e+01 6.183e+04 4.527e+05 7.32 35312 2629 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.0196e+01 1.0196e+01 1.6099e+02 1.6099e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.1057e-01 1.0422e+01 4.4430e+00 2.0126e+02 1.9684e+01 2.6040e-01 4.0000e+00 #> 2 2.8460e-02 1.0435e+01 1.0631e+00 2.1220e+02 1.2163e+01 2.4768e-01 1.6000e+01 #> 3 5.9612e-03 1.0463e+01 2.7336e-01 2.1619e+02 7.5955e+00 3.4400e-01 6.4000e+01 #> 4 1.8455e-03 1.0452e+01 6.8677e-02 2.1701e+02 6.2612e+00 1.9414e-01 2.5600e+02 #> 5 4.9396e-04 1.0456e+01 1.7247e-02 2.1695e+02 5.9175e+00 5.9511e-02 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.141832 (exponent for MLMC weak convergence) #> beta = 1.997038 (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.0455e+01 4.609e+07 2.963e+09 64.29 19907394 1654097 402588 101803 25802 #> 0.0100 1.0456e+01 8.493e+06 1.845e+08 21.72 4271774 355405 86235 22183 #> 0.0200 1.0449e+01 2.120e+06 4.612e+07 21.76 1066677 88207 21489 5568 #> 0.0500 1.0486e+01 2.395e+05 1.811e+06 7.56 143709 12008 2983 #> 0.1000 1.0371e+01 6.183e+04 4.527e+05 7.32 35312 2629 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 9.9752e+00 9.9752e+00 1.9507e+02 1.9507e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 1.8516e-01 1.0320e+01 1.5125e-01 2.0605e+02 4.5448e+01 2.6257e-01 2.0000e+00 #> 2 1.0286e-01 1.0354e+01 4.2899e-02 2.1216e+02 3.0678e+01 1.1259e-01 4.0000e+00 #> 3 5.3252e-02 1.0312e+01 1.1354e-02 2.1187e+02 1.6533e+01 1.5358e-01 8.0000e+00 #> 4 2.8970e-02 1.0798e+01 3.3326e-03 2.2566e+02 1.3345e+01 7.2728e-01 1.6000e+01 #> 5 1.4151e-02 1.0423e+01 8.3526e-04 2.1640e+02 1.3669e+01 6.1601e-01 3.2000e+01 #> 6 7.3986e-03 1.0704e+01 2.2395e-04 2.2544e+02 1.1963e+01 4.3338e-01 6.4000e+01 #> 7 3.4873e-03 1.0387e+01 5.1566e-05 2.1071e+02 9.6595e+00 5.1188e-01 1.2800e+02 #> 8 1.7975e-03 1.0456e+01 1.3383e-05 2.1602e+02 9.6563e+00 1.0901e-01 2.5600e+02 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.961837 (exponent for MLMC weak convergence) #> beta = 1.925465 (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.0455e+01 1.354e+07 2.949e+09 217.77 11895928 238691 87730 32761 11721 4273 1647 595 200 #> 0.0100 1.0451e+01 3.392e+06 3.596e+08 106.03 2965597 57209 29757 8110 3033 1091 404 144 #> 0.0200 1.0436e+01 8.268e+05 4.809e+07 58.17 733803 14002 5317 2084 757 274 97 #> 0.0500 1.0425e+01 1.300e+05 3.693e+06 28.41 115840 2548 892 317 108 39 #> 0.1000 1.0417e+01 3.399e+04 4.814e+05 14.16 29912 873 224 104 38 #> 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 9.9752e+00 9.9752e+00 1.9507e+02 1.9507e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 1.8516e-01 1.0320e+01 1.5125e-01 2.0605e+02 4.5448e+01 2.6257e-01 2.0000e+00 #> 2 1.0286e-01 1.0354e+01 4.2899e-02 2.1216e+02 3.0678e+01 1.1259e-01 4.0000e+00 #> 3 5.3252e-02 1.0312e+01 1.1354e-02 2.1187e+02 1.6533e+01 1.5358e-01 8.0000e+00 #> 4 2.8970e-02 1.0798e+01 3.3326e-03 2.2566e+02 1.3345e+01 7.2728e-01 1.6000e+01 #> 5 1.4151e-02 1.0423e+01 8.3526e-04 2.1640e+02 1.3669e+01 6.1601e-01 3.2000e+01 #> 6 7.3986e-03 1.0704e+01 2.2395e-04 2.2544e+02 1.1963e+01 4.3338e-01 6.4000e+01 #> 7 3.4873e-03 1.0387e+01 5.1566e-05 2.1071e+02 9.6595e+00 5.1188e-01 1.2800e+02 #> 8 1.7975e-03 1.0456e+01 1.3383e-05 2.1602e+02 9.6563e+00 1.0901e-01 2.5600e+02 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.961837 (exponent for MLMC weak convergence) #> beta = 1.925465 (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.0455e+01 1.354e+07 2.949e+09 217.77 11895928 238691 87730 32761 11721 4273 1647 595 200 #> 0.0100 1.0451e+01 3.392e+06 3.596e+08 106.03 2965597 57209 29757 8110 3033 1091 404 144 #> 0.0200 1.0436e+01 8.268e+05 4.809e+07 58.17 733803 14002 5317 2084 757 274 97 #> 0.0500 1.0425e+01 1.300e+05 3.693e+06 28.41 115840 2548 892 317 108 39 #> 0.1000 1.0417e+01 3.399e+04 4.814e+05 14.16 29912 873 224 104 38 #> 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.0232e+01 1.0232e+01 1.5823e+02 1.5823e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 1.9481e-01 1.0313e+01 4.5620e+00 2.0120e+02 2.1503e+01 1.3030e-01 4.0000e+00 #> 2 3.3953e-02 1.0629e+01 1.0900e+00 2.1325e+02 1.1524e+01 3.1512e-01 1.6000e+01 #> 3 6.7849e-03 1.0348e+01 2.6568e-01 2.0846e+02 8.2740e+00 3.2525e-01 6.4000e+01 #> 4 1.2933e-03 1.0592e+01 6.9911e-02 2.1665e+02 5.9317e+00 2.7516e-01 2.5600e+02 #> 5 1.6629e-03 1.0420e+01 1.7553e-02 2.1756e+02 6.3481e+00 1.9562e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 1.845878 (exponent for MLMC weak convergence) #> beta = 2.000624 (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.0455e+01 1.348e+06 2.846e+07 21.11 681953 56853 13713 3428 #> 0.1000 1.0429e+01 6.355e+04 4.549e+05 7.16 35700 2963 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.9662e+00 9.9662e+00 1.9301e+02 1.9301e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 1.8497e-01 1.0252e+01 1.4717e-01 2.0805e+02 3.5050e+01 1.1762e-01 2.0000e+00 #> 2 1.0443e-01 1.0462e+01 4.2785e-02 2.1483e+02 2.4410e+01 1.2022e-01 4.0000e+00 #> 3 5.4997e-02 1.0541e+01 1.1994e-02 2.1655e+02 1.8253e+01 2.6352e-02 8.0000e+00 #> 4 2.9120e-02 1.0736e+01 3.3241e-03 2.2103e+02 1.4422e+01 1.8669e-01 1.6000e+01 #> 5 1.4115e-02 1.0361e+01 8.3478e-04 2.1369e+02 1.1162e+01 4.3886e-01 3.2000e+01 #> 6 6.9755e-03 1.0358e+01 2.0620e-04 2.1376e+02 1.1453e+01 1.1802e-02 6.4000e+01 #> 7 3.6329e-03 1.0607e+01 5.4272e-05 2.1635e+02 1.1230e+01 2.7890e-01 1.2800e+02 #> 8 1.7866e-03 1.0468e+01 1.3504e-05 2.1960e+02 1.0223e+01 1.5951e-01 2.5600e+02 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 0.965073 (exponent for MLMC weak convergence) #> beta = 1.923518 (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.0427e+01 5.301e+05 2.919e+07 55.06 469429 8857 3386 1412 509 172 70 #> 0.1000 1.0350e+01 3.621e+04 4.715e+05 13.02 28934 1000 1000 95 32 #>"},{"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.0190e+01 1.0190e+01 1.6101e+02 1.6101e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.1145e-01 1.0421e+01 4.4649e+00 2.0152e+02 2.0357e+01 2.2485e-01 4.0000e+00 #> 2 3.0094e-02 1.0443e+01 1.0645e+00 2.1265e+02 1.2213e+01 9.1521e-02 1.6000e+01 #> 3 5.6597e-03 1.0442e+01 2.7227e-01 2.1523e+02 7.6011e+00 7.8199e-02 6.4000e+01 #> 4 1.5063e-03 1.0456e+01 6.8945e-02 2.1684e+02 6.3145e+00 1.4833e-01 2.5600e+02 #> 5 5.9454e-04 1.0444e+01 1.7243e-02 2.1583e+02 5.9149e+00 1.4228e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.126907 (exponent for MLMC weak convergence) #> beta = 1.998164 (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.0447e+01 4.622e+07 2.961e+09 64.05 19926135 1657315 404995 102366 25924 #> 0.0100 1.0452e+01 8.464e+06 1.837e+08 21.70 4264911 354826 86738 21742 #> 0.0200 1.0479e+01 2.144e+06 4.592e+07 21.42 1073618 89427 21938 5647 #> 0.0500 1.0450e+01 2.462e+05 1.815e+06 7.37 152423 12210 2811 #> 0.1000 1.0471e+01 6.718e+04 4.536e+05 6.75 38401 3195 1000 #> #> #> Exact value: 10.450584, MLMC value: 10.447168 #> #> ---- 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.1039e+00 5.1039e+00 4.0293e+01 4.0293e+01 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 6.0032e-01 5.7066e+00 1.5915e+01 5.7602e+01 4.8836e+00 4.4714e-02 4.0000e+00 #> 2 4.9725e-02 5.7615e+00 1.4242e+00 6.2242e+01 5.9414e+00 1.0466e-01 1.6000e+01 #> 3 5.6281e-03 5.7766e+00 1.5273e-01 6.3428e+01 6.2011e+00 1.9430e-01 6.4000e+01 #> 4 7.9738e-04 5.7513e+00 2.4887e-02 6.3392e+01 5.9353e+00 5.4184e-01 2.5600e+02 #> 5 2.2619e-04 5.7534e+00 5.3805e-03 6.3495e+01 5.6904e+00 3.8895e-02 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.871053 (exponent for MLMC weak convergence) #> beta = 2.889940 (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.7643e+00 2.728e+07 2.165e+08 7.94 7656043 2406391 360110 66135 #> 0.0100 5.7582e+00 6.791e+06 5.413e+07 7.97 1908674 599483 89531 16443 #> 0.0200 5.7394e+00 1.718e+06 1.353e+07 7.88 481200 151668 22704 4170 #> 0.0500 5.7950e+00 1.952e+05 5.311e+05 2.72 64857 20311 3066 #> 0.1000 5.7332e+00 5.266e+04 1.328e+05 2.52 16090 5142 1000 #> #> #> Exact value unknown, MLMC value: 5.764282 #> #> ---- 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.0658e+01 2.0658e+01 1.7529e+02 1.7529e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 -2.5116e+00 1.8108e+01 1.3943e+01 1.9878e+02 4.4978e+00 4.0534e-01 4.0000e+00 #> 2 -6.9227e-01 1.7453e+01 4.8871e+00 2.0963e+02 4.0202e+00 3.9640e-01 1.6000e+01 #> 3 -1.8064e-01 1.7268e+01 1.4316e+00 2.1166e+02 3.7982e+00 4.7191e-02 6.4000e+01 #> 4 -4.4695e-02 1.7256e+01 3.8803e-01 2.1360e+02 3.7314e+00 3.6932e-01 2.5600e+02 #> 5 -1.1395e-02 1.7228e+01 1.0062e-01 2.1308e+02 3.7048e+00 1.8273e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 1.952122 (exponent for MLMC weak convergence) #> beta = 1.788375 (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.7218e+01 4.764e+07 2.909e+09 61.06 10553225 1490221 439115 118801 31047 8353 #> 0.0200 1.7230e+01 1.199e+07 7.273e+08 60.67 2649178 375181 110072 29909 7829 2107 #> 0.0500 1.7222e+01 1.299e+06 2.916e+07 22.45 348339 49126 14458 3950 1054 #> 0.1000 1.7344e+01 3.310e+05 7.291e+06 22.03 88103 12417 3620 1018 274 #> 0.2000 1.7377e+01 5.614e+04 4.515e+05 8.04 17523 2469 1000 199 #> #> #> Exact value: 17.216802, MLMC value: 17.217921 #> #> ---- 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.6990e+01 5.6990e+01 2.1732e+03 2.1732e+03 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 -2.7915e+00 5.4128e+01 2.5774e+02 2.2190e+03 3.2106e+01 4.2415e-01 4.0000e+00 #> 2 -6.9927e-01 5.3474e+01 1.6554e+02 2.2271e+03 5.4194e+01 2.7650e-01 1.6000e+01 #> 3 -1.6958e-01 5.3303e+01 8.6449e+01 2.2291e+03 1.0456e+02 7.1852e-03 6.4000e+01 #> 4 -4.6158e-02 5.3230e+01 4.3383e+01 2.2300e+03 2.0854e+02 1.7451e-01 2.5600e+02 #> 5 -1.0844e-02 5.3216e+01 2.1435e+01 2.2301e+03 4.2211e+02 2.4322e-02 1.0240e+03 #> #> WARNING: kurtosis on finest level = 422.114439 #> 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.993719 (exponent for MLMC weak convergence) #> beta = 0.910770 (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.3256e+01 7.140e+08 7.612e+09 10.66 71927300 12390737 4961618 1801584 632022 230472 #> 0.0500 5.3235e+01 5.430e+07 3.045e+08 5.61 7934620 1367595 549185 204028 74401 #> 0.1000 5.3231e+01 1.320e+07 7.612e+07 5.77 1955414 337337 135584 49074 17895 #> 0.2000 5.3392e+01 1.362e+06 4.755e+06 3.49 314162 53918 20684 7827 #> 0.5000 5.2787e+01 2.450e+05 7.609e+05 3.11 53156 9434 3822 1452 #> #> #> Exact value: 53.232482, MLMC value: 53.256370 #> #> ---- 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.0207e+01 1.0207e+01 1.6089e+02 1.6089e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.1326e-01 1.0420e+01 3.5529e+00 1.9071e+02 1.4748e+01 2.8790e-03 4.0000e+00 #> 2 3.4245e-02 1.0438e+01 3.6981e+00 1.9162e+02 7.3462e+00 2.6720e-01 1.6000e+01 #> 3 7.2058e-03 1.0447e+01 1.7474e+00 1.9185e+02 6.1217e+00 3.7705e-02 6.4000e+01 #> 4 1.0090e-03 1.0458e+01 5.1187e-01 1.9171e+02 5.5768e+00 1.5339e-01 2.5600e+02 #> 5 9.6171e-05 1.0474e+01 1.3363e-01 1.9202e+02 5.4543e+00 2.7100e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.731437 (exponent for MLMC weak convergence) #> beta = 1.231829 (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.0454e+01 6.432e+07 6.548e+08 10.18 23506656 1743584 890673 305993 #> 0.0100 1.0450e+01 1.610e+07 1.637e+08 10.17 5881570 436419 222705 76735 #> 0.0200 1.0440e+01 1.968e+06 1.022e+07 5.19 1047180 75445 38698 #> 0.0500 1.0471e+01 3.138e+05 1.635e+06 5.21 163782 12814 6170 #> 0.1000 1.0431e+01 8.048e+04 4.088e+05 5.08 42297 3191 1589 #> #> #> Exact value unknown, MLMC value: 10.454337 # } # The level sampler can be called directly to retrieve the relevant level sums: opre_l(l = 7, N = 10, option = 1) #> $sums #> [1] -1.894700e-03 8.694623e-03 -1.054083e-04 2.305858e-05 3.726061e+01 #> [6] 3.477253e+02 #> #> $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.0202e+01 1.0202e+01 1.6129e+02 1.6129e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.1014e-01 1.0417e+01 4.4552e+00 2.0129e+02 1.9673e+01 8.0284e-02 4.0000e+00 #> 2 2.8422e-02 1.0428e+01 1.0613e+00 2.1264e+02 1.1720e+01 2.7044e-01 1.6000e+01 #> 3 5.9586e-03 1.0423e+01 2.7188e-01 2.1507e+02 7.5254e+00 1.7456e-01 6.4000e+01 #> 4 1.4902e-03 1.0437e+01 6.8853e-02 2.1588e+02 6.2866e+00 2.0275e-01 2.5600e+02 #> 5 3.2438e-04 1.0467e+01 1.7287e-02 2.1681e+02 5.9238e+00 4.6968e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.293234 (exponent for MLMC weak convergence) #> beta = 1.996557 (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.0445e+01 3.387e+07 7.341e+08 21.67 17049661 1419280 346601 87520 #> 0.0100 1.0451e+01 8.457e+06 1.835e+08 21.70 4262024 352482 86700 21841 #> 0.0200 1.0462e+01 2.141e+06 4.588e+07 21.43 1072807 89338 22072 5588 #> 0.0500 1.0496e+01 2.471e+05 1.815e+06 7.34 149418 12491 2983 #> 0.1000 1.0467e+01 6.762e+04 4.536e+05 6.71 38372 3313 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.0202e+01 1.0202e+01 1.6129e+02 1.6129e+02 0.0000e+00 0.0000e+00 1.0000e+00 #> 1 2.1014e-01 1.0417e+01 4.4552e+00 2.0129e+02 1.9673e+01 8.0284e-02 4.0000e+00 #> 2 2.8422e-02 1.0428e+01 1.0613e+00 2.1264e+02 1.1720e+01 2.7044e-01 1.6000e+01 #> 3 5.9586e-03 1.0423e+01 2.7188e-01 2.1507e+02 7.5254e+00 1.7456e-01 6.4000e+01 #> 4 1.4902e-03 1.0437e+01 6.8853e-02 2.1588e+02 6.2866e+00 2.0275e-01 2.5600e+02 #> 5 3.2438e-04 1.0467e+01 1.7287e-02 2.1681e+02 5.9238e+00 4.6968e-01 1.0240e+03 #> #> ****************************************************** #> *** Linear regression estimates of MLMC parameters *** #> ****************************************************** #> #> alpha = 2.293234 (exponent for MLMC weak convergence) #> beta = 1.996557 (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.0445e+01 3.387e+07 7.341e+08 21.67 17049661 1419280 346601 87520 #> 0.0100 1.0451e+01 8.457e+06 1.835e+08 21.70 4262024 352482 86700 21841 #> 0.0200 1.0462e+01 2.141e+06 4.588e+07 21.43 1072807 89338 22072 5588 #> 0.0500 1.0496e+01 2.471e+05 1.815e+06 7.34 149418 12491 2983 #> 0.1000 1.0467e+01 6.762e+04 4.536e+05 6.71 38372 3313 1000 #> plot(tst) # }"},{"path":"https://mlmc.louisaslett.com/news/index.html","id":"mlmc-201","dir":"Changelog","previous_headings":"","what":"mlmc 2.0.1","title":"mlmc 2.0.1","text":"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":""}]