adding material

This commit is contained in:
Morten Hjorth-Jensen
2022-09-08 17:13:24 +02:00
parent 01cecea364
commit 6f107c1399
9 changed files with 1176 additions and 1176 deletions
+1 -1
View File
@@ -1319,7 +1319,7 @@ C(\bm{X},\bm{\beta})=\left\{(\bm{y}-\bm{X}\bm{\beta})^T(\bm{y}-\bm{X}\bm{\beta})
Taking the derivative with respect to $\bm{\beta}$ and recalling that the derivative of the absolute value is (we drop the boldfaced vector symbol for simplicty)
!bt
\[
\frac{d \vert \beta\vert}{d \bm{\beta}}=\mathrm{sgn}(\bm{\beta})=\left\{\begin{array}{cc} 1 & \beta > 0 \\ 0 & \beta =0\\-1 & \beta < 0, \end{array}\right.
\frac{d \vert \beta\vert}{d \bm{\beta}}=\mathrm{sgn}(\bm{\beta})=\left\{\begin{array}{cc} 1 & \beta > 0 \\-1 & \beta < 0, \end{array}\right.
\]
!et
we have that the derivative of the cost function is
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large Load Diff
+59 -59
View File
@@ -1204,10 +1204,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.030407120354722424
3.7843182645426894
[[ 1.22134069 3.4744219 ]
[ 3.4744219 10.84203538]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-0.02697521163514974
3.9835443722554817
[[ 0.98467494 3.11283168]
[ 3.11283168 10.68965135]]
</pre></div>
</div>
</div>
@@ -1244,10 +1244,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.09023660662586945
1.5216048821598704
[[1. 0.62896882]
[0.62896882 1. ]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.07898165660100093
1.6984511994530214
[[1. 0.63862189]
[0.63862189 1. ]]
</pre></div>
</div>
</div>
@@ -1277,30 +1277,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.30936179 -2.92208477]
[ 0.61757228 1.64238022]
[ 0.23816792 1.87666423]
[-0.45402701 -2.54845458]
[ 0.26848435 0.35074881]
[-0.92143477 -1.96473528]
[ 0.10516924 -0.36535019]
[ 0.70721787 3.41211579]
[ 0.75819326 1.03069324]
[-0.00998135 -0.51197747]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[ 1.49901244 6.93685631]
[-1.07535606 -4.3823886 ]
[-1.23168292 -4.3014751 ]
[ 1.37683438 3.52093124]
[ 1.31424359 3.63367582]
[-1.15269628 -1.86879198]
[-0.93188452 -4.26291585]
[-0.66295776 -1.21924917]
[ 0.29883607 -0.44270138]
[ 0.56565106 2.38605872]]
0 1
0 -1.309362 -2.922085
1 0.617572 1.642380
2 0.238168 1.876664
3 -0.454027 -2.548455
4 0.268484 0.350749
5 -0.921435 -1.964735
6 0.105169 -0.365350
7 0.707218 3.412116
8 0.758193 1.030693
9 -0.009981 -0.511977
0 1.499012 6.936856
1 -1.075356 -4.382389
2 -1.231683 -4.301475
3 1.376834 3.520931
4 1.314244 3.633676
5 -1.152696 -1.868792
6 -0.931885 -4.262916
7 -0.662958 -1.219249
8 0.298836 -0.442701
9 0.565651 2.386059
0 1
0 1.000000 0.889686
1 0.889686 1.000000
0 1.000000 0.946393
1 0.946393 1.000000
</pre></div>
</div>
</div>
@@ -1357,37 +1357,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.092621 0.084912 0.094477 0.085405 0.077338 0.086802 0.078432
2 0.0 0.084912 0.079260 0.088946 0.081311 0.074401 0.083242 0.075899
3 0.0 0.094477 0.088946 0.102401 0.093930 0.086203 0.097710 0.089206
4 0.0 0.085405 0.081311 0.093930 0.086841 0.080288 0.090630 0.083300
5 0.0 0.077338 0.074401 0.086203 0.080288 0.074743 0.084032 0.077724
6 0.0 0.086802 0.083242 0.097710 0.090630 0.084032 0.095617 0.088029
7 0.0 0.078432 0.075899 0.089206 0.083300 0.077724 0.088029 0.081520
8 0.0 0.071086 0.069386 0.081637 0.076726 0.072021 0.081198 0.075618
9 0.0 0.064634 0.063612 0.074905 0.070835 0.066873 0.075058 0.070276
10 0.0 0.078704 0.076525 0.090849 0.085027 0.079495 0.090503 0.083913
11 0.0 0.071326 0.069907 0.083000 0.078157 0.073489 0.083251 0.077607
12 0.0 0.064859 0.064062 0.076055 0.072041 0.068110 0.076783 0.071949
13 0.0 0.059180 0.058890 0.069903 0.066590 0.063287 0.071009 0.066870
14 0.0 0.054182 0.054305 0.064442 0.061725 0.058957 0.065846 0.062305
1 0.0 0.096516 0.086951 0.097634 0.093624 0.089369 0.089758 0.086888
2 0.0 0.086951 0.079242 0.086994 0.083832 0.080479 0.079719 0.077419
3 0.0 0.097634 0.086994 0.105161 0.100303 0.095184 0.100358 0.096893
4 0.0 0.093624 0.083832 0.100303 0.095935 0.091315 0.095522 0.092409
5 0.0 0.089369 0.080479 0.095184 0.091315 0.087208 0.090451 0.087689
6 0.0 0.089758 0.079719 0.100358 0.095522 0.090451 0.098135 0.094657
7 0.0 0.086888 0.077419 0.096893 0.092409 0.087689 0.094657 0.091440
8 0.0 0.084096 0.075188 0.093497 0.089355 0.084979 0.091236 0.088271
9 0.0 0.081343 0.072994 0.090128 0.086322 0.082286 0.087833 0.085113
10 0.0 0.081707 0.072554 0.093593 0.089041 0.084278 0.093078 0.089775
11 0.0 0.079268 0.070562 0.090694 0.086420 0.081932 0.090174 0.087081
12 0.0 0.076942 0.068664 0.087910 0.083899 0.079676 0.087372 0.084477
13 0.0 0.074715 0.066850 0.085224 0.081468 0.077499 0.084657 0.081953
14 0.0 0.072575 0.065110 0.082620 0.079110 0.075389 0.082014 0.079493
8 9 10 11 12 13 14
0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.071086 0.064634 0.078704 0.071326 0.064859 0.059180 0.054182
2 0.069386 0.063612 0.076525 0.069907 0.064062 0.058890 0.054305
3 0.081637 0.074905 0.090849 0.083000 0.076055 0.069903 0.064442
4 0.076726 0.070835 0.085027 0.078157 0.072041 0.066590 0.061725
5 0.072021 0.066873 0.079495 0.073489 0.068110 0.063287 0.058957
6 0.081198 0.075058 0.090503 0.083251 0.076783 0.071009 0.065846
7 0.075618 0.070276 0.083913 0.077607 0.071949 0.066870 0.062305
8 0.070518 0.065869 0.077921 0.072435 0.067484 0.063014 0.058974
9 0.065869 0.061821 0.072483 0.067710 0.063375 0.059437 0.055859
10 0.077921 0.072483 0.086809 0.080332 0.074513 0.069281 0.064573
11 0.072435 0.067710 0.080332 0.074708 0.069626 0.065032 0.060875
12 0.067484 0.063375 0.074513 0.069626 0.065183 0.061144 0.057469
13 0.063014 0.059437 0.069281 0.065032 0.061144 0.057588 0.054335
14 0.058974 0.055859 0.064573 0.060875 0.057469 0.054335 0.051451
1 0.084096 0.081343 0.081707 0.079268 0.076942 0.074715 0.072575
2 0.075188 0.072994 0.072554 0.070562 0.068664 0.066850 0.065110
3 0.093497 0.090128 0.093593 0.090694 0.087910 0.085224 0.082620
4 0.089355 0.086322 0.089041 0.086420 0.083899 0.081468 0.079110
5 0.084979 0.082286 0.084278 0.081932 0.079676 0.077499 0.075389
6 0.091236 0.087833 0.093078 0.090174 0.087372 0.084657 0.082014
7 0.088271 0.085113 0.089775 0.087081 0.084477 0.081953 0.079493
8 0.085345 0.082426 0.086518 0.084024 0.081613 0.079273 0.076990
9 0.082426 0.079741 0.083272 0.080973 0.078749 0.076588 0.074480
10 0.086518 0.083272 0.089374 0.086610 0.083935 0.081334 0.078795
11 0.084024 0.080973 0.086610 0.084017 0.081503 0.079056 0.076665
12 0.081613 0.078749 0.083935 0.081503 0.079142 0.076843 0.074592
13 0.079273 0.076588 0.081334 0.079056 0.076843 0.074684 0.072569
14 0.076990 0.074480 0.078795 0.076665 0.074592 0.072569 0.070585
</pre></div>
</div>
</div>
@@ -1650,7 +1650,7 @@ C(\boldsymbol{X},\boldsymbol{\beta})=\left\{(\boldsymbol{y}-\boldsymbol{X}\bolds
<p>Taking the derivative with respect to <span class="math notranslate nohighlight">\(\boldsymbol{\beta}\)</span> and recalling that the derivative of the absolute value is (we drop the boldfaced vector symbol for simplicty)</p>
<div class="math notranslate nohighlight">
\[\begin{split}
\frac{d \vert \beta\vert}{d \boldsymbol{\beta}}=\mathrm{sgn}(\boldsymbol{\beta})=\left\{\begin{array}{cc} 1 &amp; \beta &gt; 0 \\ 0 &amp; \beta =0\\-1 &amp; \beta &lt; 0, \end{array}\right.
\frac{d \vert \beta\vert}{d \boldsymbol{\beta}}=\mathrm{sgn}(\boldsymbol{\beta})=\left\{\begin{array}{cc} 1 &amp; \beta &gt; 0 \\-1 &amp; \beta &lt; 0, \end{array}\right.
\end{split}\]</div>
<p>we have that the derivative of the cost function is</p>
<div class="math notranslate nohighlight">
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
@@ -1188,7 +1188,7 @@ print(covariance_matrix)
# Taking the derivative with respect to $\boldsymbol{\beta}$ and recalling that the derivative of the absolute value is (we drop the boldfaced vector symbol for simplicty)
# $$
# \frac{d \vert \beta\vert}{d \boldsymbol{\beta}}=\mathrm{sgn}(\boldsymbol{\beta})=\left\{\begin{array}{cc} 1 & \beta > 0 \\ 0 & \beta =0\\-1 & \beta < 0, \end{array}\right.
# \frac{d \vert \beta\vert}{d \boldsymbol{\beta}}=\mathrm{sgn}(\boldsymbol{\beta})=\left\{\begin{array}{cc} 1 & \beta > 0 \\-1 & \beta < 0, \end{array}\right.
# $$
# we have that the derivative of the cost function is
File diff suppressed because it is too large Load Diff