typos in pca
This commit is contained in:
@@ -224,7 +224,7 @@ MathJax.Hub.Config({
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>Jan 2, 2020</h4></center> <!-- date -->
|
||||
<center><h4>Jan 3, 2020</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ specific case.
|
||||
<h3 id="___sec19" class="anchor">Compute the sample covariance </h3>
|
||||
|
||||
<p>
|
||||
Now we are going to use the mean centered data to compute the sample covariance of the data.
|
||||
Now we are going to use the mean centered data to compute the sample covariance of the data by using the following equation
|
||||
$$
|
||||
\begin{equation*}
|
||||
\Sigma_n = \frac{1}{n-1} \sum_{i=1}^n \bar{x}_i^T \bar{x}_i = \frac{1}{n-1} \sum_{i=1}^n (x_i - \mu_n)^T (x_i - \mu_n)
|
||||
@@ -294,8 +294,8 @@ We can write our own code or simply use either the functionaly of <b>numpy</b> o
|
||||
<span style="color: #008000; font-weight: bold">print</span>(np<span style="color: #666666">.</span>cov(X_centered<span style="color: #666666">.</span>T))
|
||||
</pre></div>
|
||||
<p>
|
||||
Note that the way we define the covariance matrix here has a factor \( n-1 \) instead of \( n \).
|
||||
Our own code here is not very elegant and asks for improvements.
|
||||
Note that the way we define the covariance matrix here has a factor \( n-1 \) instead of \( n \). This is included in the <b>cov()</b> function by <b>numpy</b> and <b>pandas</b>.
|
||||
Our own code here is not very elegant and asks for obvious improvements. It is tailored to this specific \( 2\times 2 \) covariance matrix.
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
|
||||
@@ -224,7 +224,7 @@ MathJax.Hub.Config({
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>Jan 2, 2020</h4></center> <!-- date -->
|
||||
<center><h4>Jan 3, 2020</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ MathJax.Hub.Config({
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p> <br>
|
||||
<center><h4>Jan 2, 2020</h4></center> <!-- date -->
|
||||
<center><h4>Jan 3, 2020</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
|
||||
@@ -1088,7 +1088,7 @@ specific case.
|
||||
<h3 id="___sec19">Compute the sample covariance </h3>
|
||||
|
||||
<p>
|
||||
Now we are going to use the mean centered data to compute the sample covariance of the data.
|
||||
Now we are going to use the mean centered data to compute the sample covariance of the data by using the following equation
|
||||
<p> <br>
|
||||
$$
|
||||
\begin{equation*}
|
||||
@@ -1106,8 +1106,8 @@ We can write our own code or simply use either the functionaly of <b>numpy</b> o
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(np.cov(X_centered.T))
|
||||
</pre></div>
|
||||
<p>
|
||||
Note that the way we define the covariance matrix here has a factor \( n-1 \) instead of \( n \).
|
||||
Our own code here is not very elegant and asks for improvements.
|
||||
Note that the way we define the covariance matrix here has a factor \( n-1 \) instead of \( n \). This is included in the <b>cov()</b> function by <b>numpy</b> and <b>pandas</b>.
|
||||
Our own code here is not very elegant and asks for obvious improvements. It is tailored to this specific \( 2\times 2 \) covariance matrix.
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
|
||||
@@ -179,7 +179,7 @@ MathJax.Hub.Config({
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>Jan 2, 2020</h4></center> <!-- date -->
|
||||
<center><h4>Jan 3, 2020</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
@@ -1064,7 +1064,7 @@ specific case.
|
||||
<h3 id="___sec19">Compute the sample covariance </h3>
|
||||
|
||||
<p>
|
||||
Now we are going to use the mean centered data to compute the sample covariance of the data.
|
||||
Now we are going to use the mean centered data to compute the sample covariance of the data by using the following equation
|
||||
$$
|
||||
\begin{equation*}
|
||||
\Sigma_n = \frac{1}{n-1} \sum_{i=1}^n \bar{x}_i^T \bar{x}_i = \frac{1}{n-1} \sum_{i=1}^n (x_i - \mu_n)^T (x_i - \mu_n)
|
||||
@@ -1080,8 +1080,8 @@ We can write our own code or simply use either the functionaly of <b>numpy</b> o
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(np.cov(X_centered.T))
|
||||
</pre></div>
|
||||
<p>
|
||||
Note that the way we define the covariance matrix here has a factor \( n-1 \) instead of \( n \).
|
||||
Our own code here is not very elegant and asks for improvements.
|
||||
Note that the way we define the covariance matrix here has a factor \( n-1 \) instead of \( n \). This is included in the <b>cov()</b> function by <b>numpy</b> and <b>pandas</b>.
|
||||
Our own code here is not very elegant and asks for obvious improvements. It is tailored to this specific \( 2\times 2 \) covariance matrix.
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
|
||||
@@ -184,7 +184,7 @@ MathJax.Hub.Config({
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>Jan 2, 2020</h4></center> <!-- date -->
|
||||
<center><h4>Jan 3, 2020</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
@@ -1069,7 +1069,7 @@ specific case.
|
||||
<h3 id="___sec19">Compute the sample covariance </h3>
|
||||
|
||||
<p>
|
||||
Now we are going to use the mean centered data to compute the sample covariance of the data.
|
||||
Now we are going to use the mean centered data to compute the sample covariance of the data by using the following equation
|
||||
$$
|
||||
\begin{equation*}
|
||||
\Sigma_n = \frac{1}{n-1} \sum_{i=1}^n \bar{x}_i^T \bar{x}_i = \frac{1}{n-1} \sum_{i=1}^n (x_i - \mu_n)^T (x_i - \mu_n)
|
||||
@@ -1085,8 +1085,8 @@ We can write our own code or simply use either the functionaly of <b>numpy</b> o
|
||||
<span style="color: #008000; font-weight: bold">print</span>(np<span style="color: #666666">.</span>cov(X_centered<span style="color: #666666">.</span>T))
|
||||
</pre></div>
|
||||
<p>
|
||||
Note that the way we define the covariance matrix here has a factor \( n-1 \) instead of \( n \).
|
||||
Our own code here is not very elegant and asks for improvements.
|
||||
Note that the way we define the covariance matrix here has a factor \( n-1 \) instead of \( n \). This is included in the <b>cov()</b> function by <b>numpy</b> and <b>pandas</b>.
|
||||
Our own code here is not very elegant and asks for obvious improvements. It is tailored to this specific \( 2\times 2 \) covariance matrix.
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"<!-- Author: --> \n",
|
||||
"**Morten Hjorth-Jensen**, Department of Physics, University of Oslo and Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University\n",
|
||||
"\n",
|
||||
"Date: **Jan 2, 2020**\n",
|
||||
"Date: **Jan 3, 2020**\n",
|
||||
"\n",
|
||||
"Copyright 1999-2020, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license\n",
|
||||
"\n",
|
||||
@@ -1192,7 +1192,7 @@
|
||||
"\n",
|
||||
"### Compute the sample covariance\n",
|
||||
"\n",
|
||||
"Now we are going to use the mean centered data to compute the sample covariance of the data."
|
||||
"Now we are going to use the mean centered data to compute the sample covariance of the data by using the following equation"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1228,8 +1228,8 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Note that the way we define the covariance matrix here has a factor $n-1$ instead of $n$.\n",
|
||||
"Our own code here is not very elegant and asks for improvements."
|
||||
"Note that the way we define the covariance matrix here has a factor $n-1$ instead of $n$. This is included in the **cov()** function by **numpy** and **pandas**. \n",
|
||||
"Our own code here is not very elegant and asks for obvious improvements. It is tailored to this specific $2\\times 2$ covariance matrix."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -829,7 +829,7 @@ specific case.
|
||||
|
||||
=== Compute the sample covariance ===
|
||||
|
||||
Now we are going to use the mean centered data to compute the sample covariance of the data.
|
||||
Now we are going to use the mean centered data to compute the sample covariance of the data by using the following equation
|
||||
!bt
|
||||
\begin{equation*}
|
||||
\Sigma_n = \frac{1}{n-1} \sum_{i=1}^n \bar{x}_i^T \bar{x}_i = \frac{1}{n-1} \sum_{i=1}^n (x_i - \mu_n)^T (x_i - \mu_n)
|
||||
@@ -841,8 +841,8 @@ We can write our own code or simply use either the functionaly of _numpy_ or tha
|
||||
print(df.cov())
|
||||
print(np.cov(X_centered.T))
|
||||
!ec
|
||||
Note that the way we define the covariance matrix here has a factor $n-1$ instead of $n$.
|
||||
Our own code here is not very elegant and asks for improvements.
|
||||
Note that the way we define the covariance matrix here has a factor $n-1$ instead of $n$. This is included in the _cov()_ function by _numpy_ and _pandas_.
|
||||
Our own code here is not very elegant and asks for obvious improvements. It is tailored to this specific $2\times 2$ covariance matrix.
|
||||
!bc pycod
|
||||
# extract the relevant columns from the centered design matrix of dim n x 2
|
||||
x = X_centered[:,0]
|
||||
|
||||
Reference in New Issue
Block a user