typos in pca

This commit is contained in:
mhjensen
2020-01-03 11:12:22 +01:00
parent 011f787528
commit 59d4b6253d
10 changed files with 24 additions and 24 deletions
+3 -3
View File
@@ -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]