.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/monte_carlo/quasi_monte_carlo/plot_05_paskov_traub.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via JupyterLite. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_monte_carlo_quasi_monte_carlo_plot_05_paskov_traub.py: Paskov-Traub: QMC in high dimension =================================== Theory said quasi-Monte Carlo should lose its edge beyond a dozen dimensions, since :math:`(\log N)^d / N` only beats :math:`N^{-1/2}` for astronomically large :math:`N`. Spassimir Paskov and Joseph Traub (1995) priced a Goldman Sachs collateralized mortgage obligation, a 360-dimensional integral, and found Sobol points beat Monte Carlo anyway. The explanation, later formalized as *effective dimension*: financial integrands depend mostly on a few coordinates and their low-order interactions. Here: a discretely monitored arithmetic Asian call on 64 dates, a 64-dimensional integral, with Sobol increments driving the steps in time order (:func:`financialkit.integrators.sobol_increments` with ``bridge=False``). .. GENERATED FROM PYTHON SOURCE LINES 21-35 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from financialkit.integrators import gbm_paths from financialkit.monte_carlo import gbm_path_estimate from financialkit.monte_carlo.visualizers import plot_error_convergence S, K, T, r, sigma, d = 100.0, 100.0, 1.0, 0.05, 0.2, 64 def asian(paths): return np.maximum(paths[:, 1:].mean(axis=1) - K, 0.0) .. GENERATED FROM PYTHON SOURCE LINES 36-40 Standard error against paths ---------------------------- Both estimates are replicated eight times with fresh seeds; the standard errors are on the same footing. .. GENERATED FROM PYTHON SOURCE LINES 40-51 .. code-block:: Python ns = 2 ** np.arange(7, 12) results = {s: [gbm_path_estimate(asian, S, T, r, sigma, d, n, sampler=s, n_replications=8, rng=n) for n in ns] for s in ("pseudo", "sobol")} fig, axes = plt.subplots(1, 2, figsize=(12, 4)) plot_error_convergence(ns, [x.std_error for x in results["pseudo"]], ax=axes[0], label="Monte Carlo", rates=(0.5,)) plot_error_convergence(ns, [x.std_error for x in results["sobol"]], ax=axes[0], label="Sobol, 64 dimensions", rates=()) axes[0].set_title("arithmetic Asian call, 64 dates") for s in ("pseudo", "sobol"): x = results[s][-1] print(f"{s:7s}: {x.estimate:.4f} +/- {x.std_error:.4f}") .. image-sg:: /api/gallery/monte_carlo/quasi_monte_carlo/images/sphx_glr_plot_05_paskov_traub_001.png :alt: arithmetic Asian call, 64 dates :srcset: /api/gallery/monte_carlo/quasi_monte_carlo/images/sphx_glr_plot_05_paskov_traub_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none pseudo : 5.8934 +/- 0.0410 sobol : 5.8454 +/- 0.0124 .. GENERATED FROM PYTHON SOURCE LINES 52-57 The integrand's effective dimension is low ------------------------------------------ Payoff sensitivity to each Sobol coordinate, by perturbing one normal at a time: the average depends on every increment, but those of the early dates matter most, since they move more of the average. .. GENERATED FROM PYTHON SOURCE LINES 57-70 .. code-block:: Python z = np.random.default_rng(0).standard_normal((4000, d)) base = asian(gbm_paths(S, r, sigma, T, d, 4000, dW=np.sqrt(T / d) * z)[1]) sens = [] for i in range(d): zi = z.copy() zi[:, i] += 0.1 sens.append(np.mean(np.abs(asian(gbm_paths(S, r, sigma, T, d, 4000, dW=np.sqrt(T / d) * zi)[1]) - base))) axes[1].bar(np.arange(1, d + 1), sens) axes[1].set_xlabel("coordinate (time step)") axes[1].set_ylabel("mean |payoff change|") fig.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.256 seconds) .. _sphx_glr_download_api_gallery_monte_carlo_quasi_monte_carlo_plot_05_paskov_traub.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../../../lite/lab/index.html?path=api/gallery/monte_carlo/quasi_monte_carlo/plot_05_paskov_traub.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_05_paskov_traub.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_05_paskov_traub.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_05_paskov_traub.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_