This commit is contained in:
Morten Hjorth-Jensen
2024-10-21 13:45:48 +02:00
parent 0a03ba583c
commit de6a6d8bcb
144 changed files with 7186 additions and 4274 deletions
+74 -72
View File
@@ -343,6 +343,11 @@ const thebe_selector_output = ".output, .cell_output"
Week 43: Deep Learning: Constructing a Neural Network code and solving differential equations
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek43.html">
Exercises week 43
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -761,10 +766,10 @@ covariance matrix through the <strong>np.linalg.eig()</strong> function.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-0.1621766238509487
3.735490390687699
[[0.74336924 2.19036055]
[2.19036055 7.50414881]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-0.1255057631975562
3.579533981545493
[[0.80708107 2.37821193]
[2.37821193 8.11221557]]
</pre></div>
</div>
</div>
@@ -804,10 +809,10 @@ a more brute force way. Here we scale the mean values for each column of the des
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.07865450504129884
1.6463440100796987
[[1. 0.63797452]
[0.63797452 1. ]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.07588754093232836
1.3745699019323765
[[1. 0.60314576]
[0.60314576 1. ]]
</pre></div>
</div>
</div>
@@ -836,30 +841,30 @@ this matrix we easily see that it is a positive definite matrix.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[-0.00615047 -0.51495078]
[-1.23076025 -3.95226818]
[ 0.14038959 1.1457534 ]
[ 0.7408594 2.69734853]
[ 0.19517373 1.18571046]
[-0.04178558 -0.58598227]
[ 0.45796224 0.7947491 ]
[ 0.3351443 0.35268457]
[ 0.04648472 0.35436034]
[-0.63731768 -1.47740516]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[-1.4664985 -5.74309684]
[ 0.4437291 1.90952533]
[ 1.55472805 4.78691713]
[-1.49928561 -4.52502695]
[ 1.17766528 3.5035492 ]
[-1.53311882 -4.84616248]
[ 0.58757487 2.2352456 ]
[-1.60585931 -5.88080569]
[ 1.30905952 3.50820404]
[ 1.03200542 5.05165065]]
0 1
0 -0.006150 -0.514951
1 -1.230760 -3.952268
2 0.140390 1.145753
3 0.740859 2.697349
4 0.195174 1.185710
5 -0.041786 -0.585982
6 0.457962 0.794749
7 0.335144 0.352685
8 0.046485 0.354360
9 -0.637318 -1.477405
0 -1.466499 -5.743097
1 0.443729 1.909525
2 1.554728 4.786917
3 -1.499286 -4.525027
4 1.177665 3.503549
5 -1.533119 -4.846162
6 0.587575 2.235246
7 -1.605859 -5.880806
8 1.309060 3.508204
9 1.032005 5.051651
0 1
0 1.000000 0.954148
1 0.954148 1.000000
0 1.000000 0.986472
1 0.986472 1.000000
</pre></div>
</div>
</div>
@@ -916,40 +921,37 @@ this matrix we easily see that it is a positive definite matrix.</p>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 0 1 2 3 4 5 6 7 \
0 0.0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.0 0.078267 0.080363 0.077060 0.080735 0.084346 0.068278 0.071704
2 0.0 0.080363 0.084687 0.077184 0.081702 0.086410 0.067314 0.071070
3 0.0 0.077060 0.077184 0.081107 0.083982 0.086548 0.074851 0.078039
4 0.0 0.080735 0.081702 0.083982 0.087340 0.090475 0.076894 0.080380
5 0.0 0.084346 0.086410 0.086548 0.090475 0.094304 0.078548 0.082355
6 0.0 0.068278 0.067314 0.074851 0.076894 0.078548 0.071058 0.073683
7 0.0 0.071704 0.071070 0.078039 0.080380 0.082355 0.073683 0.076547
8 0.0 0.075284 0.075083 0.081283 0.083968 0.086326 0.076306 0.079429
9 0.0 0.079000 0.079369 0.084535 0.087621 0.090437 0.078867 0.082274
10 0.0 0.059805 0.058347 0.067435 0.068873 0.069916 0.065387 0.067507
11 0.0 0.062733 0.061411 0.070367 0.072006 0.073253 0.067940 0.070248
12 0.0 0.065842 0.064698 0.073442 0.075310 0.076791 0.070595 0.073109
13 0.0 0.069136 0.068226 0.076654 0.078782 0.080535 0.073340 0.076079
14 0.0 0.072615 0.072013 0.079987 0.082412 0.084486 0.076154 0.079138
1 0.0 0.083504 0.075256 0.078921 0.075567 0.072065 0.068904 0.066579
2 0.0 0.075256 0.068613 0.070518 0.067902 0.065165 0.061508 0.059695
3 0.0 0.078921 0.070518 0.080620 0.076840 0.072951 0.073809 0.071199
4 0.0 0.075567 0.067902 0.076840 0.073512 0.070072 0.070294 0.068019
5 0.0 0.072065 0.065165 0.072951 0.070072 0.067082 0.066709 0.064764
6 0.0 0.068904 0.061508 0.073809 0.070294 0.066709 0.069698 0.067255
7 0.0 0.066579 0.059695 0.071199 0.068019 0.064764 0.067255 0.065071
8 0.0 0.064363 0.057976 0.068705 0.065848 0.062910 0.064922 0.062985
9 0.0 0.062226 0.056324 0.066296 0.063752 0.061123 0.062673 0.060974
10 0.0 0.059775 0.053480 0.066103 0.063023 0.059897 0.063806 0.061651
11 0.0 0.057936 0.052040 0.064062 0.061249 0.058385 0.061895 0.059951
12 0.0 0.056217 0.050702 0.062151 0.059593 0.056978 0.060108 0.058364
13 0.0 0.054609 0.049456 0.060358 0.058043 0.055668 0.058432 0.056880
14 0.0 0.053099 0.048295 0.058671 0.056590 0.054443 0.056857 0.055488
8 9 10 11 12 13 14
0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.075284 0.079000 0.059805 0.062733 0.065842 0.069136 0.072615
2 0.075083 0.079369 0.058347 0.061411 0.064698 0.068226 0.072013
3 0.081283 0.084535 0.067435 0.070367 0.073442 0.076654 0.079987
4 0.083968 0.087621 0.068873 0.072006 0.075310 0.078782 0.082412
5 0.086326 0.090437 0.069916 0.073253 0.076791 0.080535 0.084486
6 0.076306 0.078867 0.065387 0.067940 0.070595 0.073340 0.076154
7 0.079429 0.082274 0.067507 0.070248 0.073109 0.076079 0.079138
8 0.082598 0.085762 0.069592 0.072533 0.075613 0.078825 0.082151
9 0.085762 0.089288 0.071587 0.074738 0.078051 0.081523 0.085141
10 0.069592 0.071587 0.061178 0.063336 0.065565 0.067851 0.070172
11 0.072533 0.074738 0.063336 0.065655 0.068057 0.070529 0.073050
12 0.075613 0.078051 0.065565 0.068057 0.070647 0.073320 0.076057
13 0.078825 0.081523 0.067851 0.070529 0.073320 0.076212 0.079184
14 0.082151 0.085141 0.070172 0.073050 0.076057 0.079184 0.082414
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>
1 0.064363 0.062226 0.059775 0.057936 0.056217 0.054609 0.053099
2 0.057976 0.056324 0.053480 0.052040 0.050702 0.049456 0.048295
3 0.068705 0.066296 0.066103 0.064062 0.062151 0.060358 0.058671
4 0.065848 0.063752 0.063023 0.061249 0.059593 0.058043 0.056590
5 0.062910 0.061123 0.059897 0.058385 0.056978 0.055668 0.054443
6 0.064922 0.062673 0.063806 0.061895 0.060108 0.058432 0.056857
7 0.062985 0.060974 0.061651 0.059951 0.058364 0.056880 0.055488
8 0.061136 0.059355 0.059595 0.058098 0.056703 0.055402 0.054185
9 0.059355 0.057796 0.057619 0.056315 0.055105 0.053981 0.052934
10 0.059595 0.057619 0.059363 0.057675 0.056097 0.054621 0.053236
11 0.058098 0.056315 0.057675 0.056161 0.054750 0.053432 0.052199
12 0.056703 0.055105 0.056097 0.054750 0.053497 0.052330 0.051241
13 0.055402 0.053981 0.054621 0.053432 0.052330 0.051307 0.050356
14 0.054185 0.052934 0.053236 0.052199 0.051241 0.050356 0.049538
</pre></div>
</div>
</div>
@@ -1138,10 +1140,10 @@ We can write our own code or simply use either the functionaly of <strong>numpy<
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 0 1
0 3.847343 1.919895
1 1.919895 1.934339
[[3.8473429 1.91989533]
[1.91989533 1.934339 ]]
0 3.969573 1.988769
1 1.988769 2.007390
[[3.96957289 1.98876882]
[1.98876882 2.00738983]]
</pre></div>
</div>
</div>
@@ -1168,8 +1170,8 @@ Our own code here is not very elegant and asks for obvious improvements. It is t
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Centered covariance using own code
[[3.8473429 1.91989533]
[1.91989533 1.934339 ]]
[[3.96957289 1.98876882]
[1.98876882 2.00738983]]
</pre></div>
</div>
<img alt="_images/chapter8_65_1.png" src="_images/chapter8_65_1.png" />
@@ -1229,16 +1231,16 @@ questions.</p>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Eigenvalues of Covariance matrix
5.035810431523915
0.7458714725617228
5.206079615468402
0.7708831044105582
First eigenvector
[0.8502729 0.52634209]
[0.84923841 0.52800959]
Second eigenvector
[-0.52634209 0.8502729 ]
[-0.52800959 0.84923841]
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Eigenvector of largest eigenvalue
[-0.8502729 -0.52634209]
[-0.84923841 -0.52800959]
</pre></div>
</div>
</div>