.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated_examples\economic\plot_ex2_short_rate_mean_variance.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_generated_examples_economic_plot_ex2_short_rate_mean_variance.py: Short rate mean and variance =================================== The means and variances of the simulated short rates. For each :math:`t_i`, the mean and the variance of the short rate :math:`r(t_i)` should converge to :math:`E\{r(t_i) | \mathcal{F}_{0}\}` and :math:`Var\{r(t_i) | \mathcal{F}_{0}\}`. .. seealso:: * :mod:`~economic.BasicHullWhite.HullWhite` in :mod:`~economic.BasicHullWhite` * :doc:`/libraries/economic/hull-white-simulation` notebook in the :mod:`~economic` library .. GENERATED FROM PYTHON SOURCE LINES 16-34 .. image-sg:: /generated_examples/economic/images/sphx_glr_plot_ex2_short_rate_mean_variance_001.png :alt: Mean 1000 scenarios, Mean 10000 scenarios, Variance 1000 scenarios, Variance 10000 scenarios :srcset: /generated_examples/economic/images/sphx_glr_plot_ex2_short_rate_mean_variance_001.png :class: sphx-glr-single-img .. code-block:: default import modelx as mx import matplotlib.pyplot as plt HW = mx.read_model("BasicHullWhite").HullWhite fig, axs = plt.subplots(2, 2, sharex=True, sharey=False) for size, h in zip([1000, 10000], [0, 1]): HW.scen_size = size axs[0, h].plot(range(HW.step_size + 1), HW.E_rt(), "b-") axs[0, h].plot(range(HW.step_size + 1), HW.mean_short_rate(), "r--") axs[0, h].set_title('Mean ' + str(size) + ' scenarios') axs[1, h].plot(range(HW.step_size + 1), HW.Var_rt(), "b-") axs[1, h].plot(range(HW.step_size + 1), HW.var_short_rate(), "r--") axs[1, h].set_title('Variance ' + str(size) + ' scenarios') .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.395 seconds) .. _sphx_glr_download_generated_examples_economic_plot_ex2_short_rate_mean_variance.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_ex2_short_rate_mean_variance.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_ex2_short_rate_mean_variance.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_