.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_boosting_density_representation.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. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_boosting_density_representation.py: Boosting density representation =============================== Describes how speed up histogram representation of ensemble spectral density. .. GENERATED FROM PYTHON SOURCE LINES 7-15 .. code-block:: Python # Author: Alejandro Santorum Varela # License: BSD 3-Clause import time from skrmt.ensemble import GaussianEnsemble, WishartEnsemble .. GENERATED FROM PYTHON SOURCE LINES 16-18 We can sample a random matrix of the Gaussian Ensemble with a relatively large size and plot its spectral density. .. GENERATED FROM PYTHON SOURCE LINES 18-25 .. code-block:: Python goe = GaussianEnsemble(beta=1, n=5000) t1 = time.time() goe.plot_eigval_hist(bins=60, density=False, normalize=False) t2 = time.time() .. image-sg:: /auto_examples/images/sphx_glr_plot_boosting_density_representation_001.png :alt: Eigenvalue histogram :srcset: /auto_examples/images/sphx_glr_plot_boosting_density_representation_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 26-27 The time needed to compute the previous histogram is: .. GENERATED FROM PYTHON SOURCE LINES 27-29 .. code-block:: Python print(t2-t1, 'seconds') .. rst-class:: sphx-glr-script-out .. code-block:: none 5.188860654830933 seconds .. GENERATED FROM PYTHON SOURCE LINES 30-32 We can speed up this procedure using the tridiagonal form of Gaussian Ensemble random matrices: ``tridiagonal_form=True``. .. GENERATED FROM PYTHON SOURCE LINES 32-39 .. code-block:: Python goe_tridiag = GaussianEnsemble(beta=1, n=5000, tridiagonal_form=True) t1 = time.time() goe_tridiag.plot_eigval_hist(bins=60, density=False, normalize=False) t2 = time.time() .. image-sg:: /auto_examples/images/sphx_glr_plot_boosting_density_representation_002.png :alt: Eigenvalue histogram :srcset: /auto_examples/images/sphx_glr_plot_boosting_density_representation_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 40-41 The time needed to compute the previous histogram is: .. GENERATED FROM PYTHON SOURCE LINES 41-43 .. code-block:: Python print(t2-t1, 'seconds') .. rst-class:: sphx-glr-script-out .. code-block:: none 0.2870519161224365 seconds .. GENERATED FROM PYTHON SOURCE LINES 44-45 This boosting trick can be used with Wishart Ensemble too .. GENERATED FROM PYTHON SOURCE LINES 45-52 .. code-block:: Python wre = WishartEnsemble(beta=1, p=5000, n=10000) t1 = time.time() wre.plot_eigval_hist(bins=60, density=False, normalize=False) t2 = time.time() .. image-sg:: /auto_examples/images/sphx_glr_plot_boosting_density_representation_003.png :alt: Eigenvalue histogram :srcset: /auto_examples/images/sphx_glr_plot_boosting_density_representation_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 53-54 The time needed to compute the previous histogram is: .. GENERATED FROM PYTHON SOURCE LINES 54-56 .. code-block:: Python print(t2-t1, 'seconds') .. rst-class:: sphx-glr-script-out .. code-block:: none 5.173484563827515 seconds .. GENERATED FROM PYTHON SOURCE LINES 57-58 Using tridiagonal form of the Wishart Ensemble by setting ``tridiagonal_form=True``. .. GENERATED FROM PYTHON SOURCE LINES 58-65 .. code-block:: Python wre_tridiag = WishartEnsemble(beta=1, p=5000, n=10000, tridiagonal_form=True) t1 = time.time() wre_tridiag.plot_eigval_hist(bins=60, density=False, normalize=False) t2 = time.time() .. image-sg:: /auto_examples/images/sphx_glr_plot_boosting_density_representation_004.png :alt: Eigenvalue histogram :srcset: /auto_examples/images/sphx_glr_plot_boosting_density_representation_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 66-67 The time needed to compute the previous histogram is: .. GENERATED FROM PYTHON SOURCE LINES 67-69 .. code-block:: Python print(t2-t1, 'seconds') .. rst-class:: sphx-glr-script-out .. code-block:: none 0.2900412082672119 seconds .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 14.780 seconds) .. _sphx_glr_download_auto_examples_plot_boosting_density_representation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_boosting_density_representation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_boosting_density_representation.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_boosting_density_representation.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_