.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_tutorial/plot_3_eigenvalue_independence.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_tutorial_plot_3_eigenvalue_independence.py: Eigenvalue independence ======================= In this tutorial, we highlight the fact that eigenvalues of a random matrix sample are *not* independent. However, random numbers sampled using the PDF of a spectral law (e.g. Wigner's Semicircle law) are actually drawn independently. .. GENERATED FROM PYTHON SOURCE LINES 10-14 .. code-block:: Python # Author: Alejandro Santorum Varela # License: BSD 3-Clause .. GENERATED FROM PYTHON SOURCE LINES 15-27 Independent random samples vs. eigenvalues of a random matrix sample -------------------------------------------------------------------- Using **scikit-rmt** to simulate the behaviour of the ensembles, it is possible to illustrate how the eigenvalues of a random matrix sample are not independent, since they are draw from the same matrix sample. However, random variates sampled using the PDF of a spectral law (for example, Wigner's Semicircle law) are drawn independently. We can observe this phenomenon by plotting the **histogram of a random matrix** alongside the PDF of the corresponding spectral law. This is easily done by using the function ``plot_spectral_hist_and_law`` in ``skrmt.ensemble.utils``: .. GENERATED FROM PYTHON SOURCE LINES 27-34 .. code-block:: Python from skrmt.ensemble.gaussian_ensemble import GaussianEnsemble from skrmt.ensemble.utils import plot_spectral_hist_and_law goe = GaussianEnsemble(beta=1, n=3000, tridiagonal_form=True) plot_spectral_hist_and_law(ensemble=goe, bins=60) .. image-sg:: /auto_tutorial/images/sphx_glr_plot_3_eigenvalue_independence_001.png :alt: Ensemble spectral histogram vs law PDF :srcset: /auto_tutorial/images/sphx_glr_plot_3_eigenvalue_independence_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 35-44 In the previous example, the histogram of the spectrum of a sample from the Gaussian Ensemble was plotted next to the PDF of the Wigner's Semicircle law. It can be observed that the eigenvalues of a single sample of a random matrix are *not* independent since the fluctuations of the histogram compared to Wigner's Semicircle PDF are really small. In contrast, if we compare independent random samples from the Wigner Semicircle law and the actual PDF we observe higher fluctuations for the *same sample size* (in this example, 3000). .. GENERATED FROM PYTHON SOURCE LINES 44-55 .. code-block:: Python from skrmt.ensemble.spectral_law import WignerSemicircleDistribution wsd = WignerSemicircleDistribution(beta=1) wsd.plot_empirical_pdf( sample_size=3000, bins=60, density=True, plot_law_pdf=True ) .. image-sg:: /auto_tutorial/images/sphx_glr_plot_3_eigenvalue_independence_002.png :alt: Wigner Semicircle Law - Eigenvalue histogram :srcset: /auto_tutorial/images/sphx_glr_plot_3_eigenvalue_independence_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 56-58 Similarly, this can be seen for other ensembles. For example, with the Wishart Ensemble. .. GENERATED FROM PYTHON SOURCE LINES 58-65 .. code-block:: Python from skrmt.ensemble.wishart_ensemble import WishartEnsemble from skrmt.ensemble.utils import plot_spectral_hist_and_law wre = WishartEnsemble(beta=1, p=1000, n=3000, tridiagonal_form=True) plot_spectral_hist_and_law(ensemble=wre, bins=60) .. image-sg:: /auto_tutorial/images/sphx_glr_plot_3_eigenvalue_independence_003.png :alt: Ensemble spectral histogram vs law PDF :srcset: /auto_tutorial/images/sphx_glr_plot_3_eigenvalue_independence_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 66-68 The fluctuations with respect the PDF of the Marchenko-Pastur law are larger if we directly draw independent random samples from that distribution: .. GENERATED FROM PYTHON SOURCE LINES 68-78 .. code-block:: Python from skrmt.ensemble.spectral_law import MarchenkoPasturDistribution mpd = MarchenkoPasturDistribution(beta=1, ratio=1/3) mpd.plot_empirical_pdf( sample_size=1000, bins=60, density=True, plot_law_pdf=True ) .. image-sg:: /auto_tutorial/images/sphx_glr_plot_3_eigenvalue_independence_004.png :alt: Marchenko-Pastur Law - Eigenvalue histogram :srcset: /auto_tutorial/images/sphx_glr_plot_3_eigenvalue_independence_004.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.641 seconds) .. _sphx_glr_download_auto_tutorial_plot_3_eigenvalue_independence.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_3_eigenvalue_independence.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_3_eigenvalue_independence.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_3_eigenvalue_independence.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_