This commit is contained in:
Morten Hjorth-Jensen
2024-10-14 09:13:10 +02:00
parent f1f5b33d5e
commit a7012b5326
140 changed files with 3712 additions and 3488 deletions
+82 -70
View File
@@ -323,6 +323,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 41 Neural networks and constructing a neural network code
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek42.html">
Exercises week 42
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week42.html">
Week 42 Constructing a Neural Network code with examples
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -741,10 +751,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.012423940191689783
4.101008878523571
[[0.89527291 2.65532045]
[2.65532045 8.81987609]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.1001408041761458
4.2807716628772665
[[ 1.15654145 3.54867722]
[ 3.54867722 11.70485195]]
</pre></div>
</div>
</div>
@@ -784,10 +794,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.08705631913312815
1.7026908764394864
[[1. 0.65870313]
[0.65870313 1. ]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.09543871010617433
1.6888043337746685
[[1. 0.7167077]
[0.7167077 1. ]]
</pre></div>
</div>
</div>
@@ -816,30 +826,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>[[-1.7755649 -4.56778296]
[-0.81015037 -2.80072356]
[ 0.73628249 1.95206335]
[ 0.97366347 1.61130099]
[ 0.7271324 1.97965627]
[ 0.36881837 0.56037913]
[-1.33163086 -2.59391196]
[-0.68953877 -1.58298728]
[ 0.19982428 -1.08010965]
[ 1.60116388 6.52211567]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[-0.20575734 0.01384583]
[-0.89876098 -3.04065686]
[-0.76289128 -3.17080691]
[-0.0334136 0.16124569]
[ 2.73970542 9.28885103]
[ 0.75413023 2.98474769]
[-1.87894459 -5.48121459]
[-1.26814205 -2.4848097 ]
[ 0.18114057 -0.9889962 ]
[ 1.37293361 2.71779401]]
0 1
0 -1.775565 -4.567783
1 -0.810150 -2.800724
2 0.736282 1.952063
3 0.973663 1.611301
4 0.727132 1.979656
5 0.368818 0.560379
6 -1.331631 -2.593912
7 -0.689539 -1.582987
8 0.199824 -1.080110
9 1.601164 6.522116
0 1
0 1.00000 0.94335
1 0.94335 1.00000
0 -0.205757 0.013846
1 -0.898761 -3.040657
2 -0.762891 -3.170807
3 -0.033414 0.161246
4 2.739705 9.288851
5 0.754130 2.984748
6 -1.878945 -5.481215
7 -1.268142 -2.484810
8 0.181141 -0.988996
9 1.372934 2.717794
0 1
0 1.000000 0.970965
1 0.970965 1.000000
</pre></div>
</div>
</div>
@@ -896,37 +906,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.088650 0.084209 0.092689 0.091653 0.090476 0.085764 0.085378
2 0.0 0.084209 0.080559 0.088599 0.087876 0.087020 0.082478 0.082249
3 0.0 0.092689 0.088599 0.102209 0.101292 0.100209 0.097667 0.097380
4 0.0 0.091653 0.087876 0.101292 0.100523 0.099588 0.097017 0.096811
5 0.0 0.090476 0.087020 0.100209 0.099588 0.098803 0.096203 0.096078
6 0.0 0.085764 0.082478 0.097667 0.097017 0.096203 0.095425 0.095278
7 0.0 0.085378 0.082249 0.097380 0.096811 0.096078 0.095278 0.095178
8 0.0 0.084976 0.082002 0.097060 0.096570 0.095915 0.095090 0.095037
9 0.0 0.084550 0.081730 0.096700 0.096287 0.095710 0.094857 0.094849
10 0.0 0.077672 0.075070 0.090429 0.090002 0.089421 0.089826 0.089786
11 0.0 0.077490 0.074976 0.090319 0.089940 0.089408 0.089800 0.089790
12 0.0 0.077310 0.074882 0.090204 0.089872 0.089386 0.089763 0.089783
13 0.0 0.077131 0.074787 0.090081 0.089795 0.089354 0.089714 0.089763
14 0.0 0.076951 0.074688 0.089949 0.089708 0.089311 0.089653 0.089730
1 0.0 0.090565 0.089065 0.093226 0.091674 0.090154 0.086287 0.084847
2 0.0 0.089065 0.087946 0.092421 0.091068 0.089735 0.085988 0.084674
3 0.0 0.093226 0.092421 0.102147 0.100816 0.099494 0.098144 0.096731
4 0.0 0.091674 0.091068 0.100816 0.099622 0.098431 0.097115 0.095803
5 0.0 0.090154 0.089735 0.099494 0.098431 0.097365 0.096077 0.094862
6 0.0 0.086287 0.085988 0.098144 0.097115 0.096077 0.096630 0.095395
7 0.0 0.084847 0.084674 0.096731 0.095803 0.094862 0.095395 0.094243
8 0.0 0.083459 0.083405 0.095358 0.094527 0.093680 0.094189 0.093115
9 0.0 0.082121 0.082180 0.094027 0.093288 0.092530 0.093011 0.092013
10 0.0 0.078708 0.078711 0.091732 0.090935 0.090118 0.091871 0.090804
11 0.0 0.077431 0.077523 0.090387 0.089668 0.088926 0.090626 0.089626
12 0.0 0.076203 0.076378 0.089086 0.088441 0.087772 0.089417 0.088481
13 0.0 0.075021 0.075274 0.087828 0.087255 0.086655 0.088242 0.087369
14 0.0 0.073883 0.074212 0.086611 0.086107 0.085573 0.087102 0.086289
8 9 10 11 12 13 14
0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.084976 0.084550 0.077672 0.077490 0.077310 0.077131 0.076951
2 0.082002 0.081730 0.075070 0.074976 0.074882 0.074787 0.074688
3 0.097060 0.096700 0.090429 0.090319 0.090204 0.090081 0.089949
4 0.096570 0.096287 0.090002 0.089940 0.089872 0.089795 0.089708
5 0.095915 0.095710 0.089421 0.089408 0.089386 0.089354 0.089311
6 0.095090 0.094857 0.089826 0.089800 0.089763 0.089714 0.089653
7 0.095037 0.094849 0.089786 0.089790 0.089783 0.089763 0.089730
8 0.094941 0.094797 0.089704 0.089738 0.089760 0.089769 0.089763
9 0.094797 0.094697 0.089576 0.089639 0.089690 0.089726 0.089748
10 0.089704 0.089576 0.085655 0.085690 0.085712 0.085722 0.085716
11 0.089738 0.089639 0.085690 0.085747 0.085790 0.085819 0.085833
12 0.089760 0.089690 0.085712 0.085790 0.085853 0.085902 0.085935
13 0.089769 0.089726 0.085722 0.085819 0.085902 0.085970 0.086021
14 0.089763 0.089748 0.085716 0.085833 0.085935 0.086021 0.086092
1 0.083459 0.082121 0.078708 0.077431 0.076203 0.075021 0.073883
2 0.083405 0.082180 0.078711 0.077523 0.076378 0.075274 0.074212
3 0.095358 0.094027 0.091732 0.090387 0.089086 0.087828 0.086611
4 0.094527 0.093288 0.090935 0.089668 0.088441 0.087255 0.086107
5 0.093680 0.092530 0.090118 0.088926 0.087772 0.086655 0.085573
6 0.094189 0.093011 0.091871 0.090626 0.089417 0.088242 0.087102
7 0.093115 0.092013 0.090804 0.089626 0.088481 0.087369 0.086289
8 0.092064 0.091034 0.089755 0.088642 0.087560 0.086508 0.085486
9 0.091034 0.090075 0.088726 0.087675 0.086653 0.085659 0.084694
10 0.089755 0.088726 0.088455 0.087327 0.086227 0.085155 0.084112
11 0.088642 0.087675 0.087327 0.086256 0.085212 0.084195 0.083203
12 0.087560 0.086653 0.086227 0.085212 0.084222 0.083257 0.082316
13 0.086508 0.085659 0.085155 0.084195 0.083257 0.082342 0.081450
14 0.085486 0.084694 0.084112 0.083203 0.082316 0.081450 0.080605
</pre></div>
</div>
</div>
@@ -1115,10 +1125,12 @@ 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.914672 1.954823
1 1.954823 1.963858
[[3.91467223 1.95482298]
[1.95482298 1.96385798]]
0 4.114499 2.071143
1 2.071143 2.061388
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[4.11449851 2.07114326]
[2.07114326 2.0613875 ]]
</pre></div>
</div>
</div>
@@ -1145,8 +1157,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.91467223 1.95482298]
[1.95482298 1.96385798]]
[[4.11449851 2.07114326]
[2.07114326 2.0613875 ]]
</pre></div>
</div>
<img alt="_images/chapter8_65_1.png" src="_images/chapter8_65_1.png" />
@@ -1206,16 +1218,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.123928000581825
0.7546022135629743
5.399533503407795
0.776352510835556
First eigenvector
[0.85043503 0.5260801 ]
[0.84973247 0.52721412]
Second eigenvector
[-0.5260801 0.85043503]
[-0.52721412 0.84973247]
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Eigenvector of largest eigenvalue
[0.85043503 0.5260801 ]
[-0.84973247 -0.52721412]
</pre></div>
</div>
</div>