|
12 | 12 | "\n", |
13 | 13 | "Prerequisite to this tutorial is finishing the `wigner_semicircle.ipynb` tutorial first for a background. \n", |
14 | 14 | "\n", |
15 | | - "In this lecture we will generate a mixed ensemble. A mixed ensemble implies different order matrices at a given `degree of mixture` (DoM). DoMs are a principled way to generate those different order matrices. " |
| 15 | + "In this lecture we will generate a mixed ensemble. A mixed ensemble implies different order matrices at a given `degree of mixture` (DoM). DoMs are a principled way to generate those different order matrices via `Mixed Matrix Ensemble Sampling (MMES) algoritm`. [suzen21]. " |
16 | 16 | ] |
17 | 17 | }, |
18 | 18 | { |
|
27 | 27 | "`goe` : Gaussian Orthogonal Matrix generator. \n", |
28 | 28 | "`mixed_ensemble`: Ensemble generator, for mixed ensemble. \n", |
29 | 29 | "`empirical_spectral_density`: Compute eigenvalues and their density $\\rho(\\lambda)$. \n", |
30 | | - "`wigner`: Compute the Wigner density at a given $\\lambda$.\n", |
| 30 | + "`wigner`: Compute the Wigner density.\n", |
31 | 31 | "\n", |
32 | 32 | "See each method's documentation for more details. " |
33 | 33 | ] |
|
41 | 41 | "source": [ |
42 | 42 | "import numpy as np\n", |
43 | 43 | "import matplotlib.pyplot as plt\n", |
44 | | - "from leymosun.gaussian import goe\n", |
| 44 | + "from leymosun.gaussian import goe, wigner\n", |
45 | 45 | "from leymosun.matrix import mixed_ensemble \n", |
46 | | - "from leymosun.spectral import empirical_spectral_density, wigner\n", |
| 46 | + "from leymosun.spectral import empirical_spectral_density\n", |
| 47 | + "from leymosun.stats import bootstrap_observed_matrix_ci\n", |
47 | 48 | "import leymosun\n", |
48 | 49 | "leymosun.__version__" |
49 | 50 | ] |
|
57 | 58 | "\n", |
58 | 59 | "A mixed matrix ensemble is formed by choosing different sized matrices. Recent work on this demonstrated [Suzen21] a principled way of generating a mixed ensemble. After setting a reference $N$ matrix order, generating mixed-sizes from a Binomial distribution with re-interpretation of the probability of success as the degree of mixture. This mixture defines which new matrix orders to generate and how many. \n", |
59 | 60 | "\n", |
60 | | - "The idea is to get a new matrix order $N_{i}$ at the reference matrix order $N_{ref}$ via binomimal distribution at the given probability-so called the Degree-of-Mixture (DoM) $\\mu$: $N_{i} \\sim Bin(N_{ref}, \\mu)$. Repeating this procedure with the ensemble size $M$ will generate the mixed ensembles matrix-orders we should generate. `mixed_ensemble` method from `leymosun` exactly do this. " |
| 61 | + "`Mixed Matrix Ensemble Sampling (MMES)`: The idea is to get a new matrix order $N_{i}$ at the reference matrix order $N_{ref}$ via binomimal distribution at the given probability-so called the Degree-of-Mixture (DoM) $\\mu$: $N_{i} \\sim Bin(N_{ref}, \\mu)$. Repeating this procedure with the ensemble size $M$ will generate the mixed ensembles matrix-orders we should generate. `mixed_ensemble` method from `leymosun` exactly do this. " |
61 | 62 | ] |
62 | 63 | }, |
63 | 64 | { |
|
103 | 104 | "metadata": {}, |
104 | 105 | "outputs": [], |
105 | 106 | "source": [ |
106 | | - "_, empirical_density, elocations = empirical_spectral_density(\n", |
107 | | - " ensemble_sample, mixed_order=matrix_order, scale=\"wigner\"\n", |
| 107 | + "eigenvalues, densities, locations = empirical_spectral_density(\n", |
| 108 | + " ensemble_sample, mmes_order=matrix_order, scale=\"wigner\"\n", |
108 | 109 | ")" |
109 | 110 | ] |
110 | 111 | }, |
| 112 | + { |
| 113 | + "cell_type": "markdown", |
| 114 | + "id": "57aeef26", |
| 115 | + "metadata": {}, |
| 116 | + "source": [ |
| 117 | + "We want to report 95% confidence intervals. " |
| 118 | + ] |
| 119 | + }, |
| 120 | + { |
| 121 | + "cell_type": "code", |
| 122 | + "execution_count": null, |
| 123 | + "id": "afd55df4", |
| 124 | + "metadata": {}, |
| 125 | + "outputs": [], |
| 126 | + "source": [ |
| 127 | + "observed_mean, observed_upper, observed_lower = bootstrap_observed_matrix_ci(densities)" |
| 128 | + ] |
| 129 | + }, |
111 | 130 | { |
112 | 131 | "cell_type": "markdown", |
113 | 132 | "id": "09b7e3dd", |
|
123 | 142 | "metadata": {}, |
124 | 143 | "outputs": [], |
125 | 144 | "source": [ |
126 | | - "dwigner = wigner(elocations, domain_boundary=2.0)" |
| 145 | + "dwigner = wigner(locations, domain_boundary=2.0)" |
127 | 146 | ] |
128 | 147 | }, |
129 | 148 | { |
130 | 149 | "cell_type": "markdown", |
131 | 150 | "id": "ce4b8bcf", |
132 | 151 | "metadata": {}, |
133 | 152 | "source": [ |
134 | | - "Now plotting the densities, we observer the \"Cat\" at the degree of mixture $\\mu=0.8$." |
| 153 | + "Now plotting the densities, we observer the `Wigner's Cat` (`M-shaped`) desity at the degree of mixture $\\mu=0.8$." |
135 | 154 | ] |
136 | 155 | }, |
137 | 156 | { |
|
141 | 160 | "metadata": {}, |
142 | 161 | "outputs": [], |
143 | 162 | "source": [ |
144 | | - "plt.bar(elocations, empirical_density, width=0.08, alpha=0.6, align='center')\n", |
145 | | - "plt.plot(elocations, dwigner, color='red')\n", |
146 | | - "plt.title(\"Wigner's Semicircle law with Leymosun \\n with Wigner's cat at $\\mu=0.8$ \")\n", |
| 163 | + "yerr = np.array([observed_mean-observed_lower, observed_upper-observed_mean])\n", |
| 164 | + "plt.bar(locations, observed_mean, width=0.02, alpha=0.3, align='center') \n", |
| 165 | + "plt.errorbar(locations, observed_mean, yerr=yerr, fmt=' ', capsize=5) \n", |
| 166 | + "plt.title(\"Wigner's Semicircle law with Leymosun \\n with Wigner's cat (M-shaped) density at $\\mu=0.8$ \")\n", |
147 | 167 | "plt.xlabel(\"Eigenvalue Locations\")\n", |
148 | 168 | "plt.ylabel(\"Density\")" |
149 | 169 | ] |
|
168 | 188 | "## Reference\n", |
169 | 189 | "\n", |
170 | 190 | "[Suzen21] Empirical deviations of semicircle law in mixed-matrix ensembles, M. Suzen\n", |
171 | | - "hal-03464130 (2021) [url](https://hal.science/hal-03464130)" |
| 191 | + "hal-03464130 (2021) [url](https://hal.science/hal-03464130) \n", |
| 192 | + "`Introduction of mixed matrix ensembles and MMES algorithm with M-shaped (Wigner's Cat) density.`" |
172 | 193 | ] |
173 | 194 | } |
174 | 195 | ], |
|
0 commit comments