diff --git a/doc/pub/DimRed/html/._DimRed-bs018.html b/doc/pub/DimRed/html/._DimRed-bs018.html index 0455b1a78..10609edc8 100644 --- a/doc/pub/DimRed/html/._DimRed-bs018.html +++ b/doc/pub/DimRed/html/._DimRed-bs018.html @@ -210,8 +210,8 @@ $$ \end{bmatrix} $$ -

-We will generate \( N = 1000 \) points \( X = \{ x_1, \ldots, x_N \} \) from +Note that the mean refers to each column of data. +We will generate \( n = 1000 \) points \( X = \{ x_1, \ldots, x_N \} \) from this distribution, and store them in the \( 1000 \times 2 \) matrix \( \boldsymbol{X} \).

@@ -220,13 +220,13 @@ The following Python code aids in setting up the data

-

N = 1000
+
n = 1000
 mean = (-1, 2)
 cov = [[4, 2], [2, 2]]
-X = np.random.multivariate_normal(mean, cov, N)
+X = np.random.multivariate_normal(mean, cov, n)
 

-Make a small Python code which plots the data. +Make thereafter a small Python code which plots the data. Note that the function multivariate returns also the covariance discussed above and that it is defined by dividing by \( n-1 \) instead of \( n \).

Now we are going to implement the PCA algorithm. We will break it down into sub-steps and across multiple cells. @@ -234,17 +234,17 @@ Now we are going to implement the PCA algorithm. We will break it down into sub-

Compute the sample mean and center the data

-The first step of PCA is to compute the sample mean of the data and use it to center the data. Recall the sample mean is +The first step of PCA is to compute the sample mean of the data and use it to center the data. Recall that the sample mean is $$ -\mu_N = \frac{1}{N} \sum_{i=1}^N x_i +\mu_n = \frac{1}{n} \sum_{i=1}^n x_i $$ -and the mean-centered data \( \bar{X} = \{ \bar{x}_1, \ldots, \bar{x}_N \} \) takes the form +and the mean-centered data \( \bar{X} = \{ \bar{x}_1, \ldots, \bar{x}_n \} \) takes the form $$ -\bar{x}_i = x_i - \mu_N +\bar{x}_i = x_i - \mu_n. $$ -When you are done with these steps, print out \( \mu_N \) to verify it is +When you are done with these steps, print out \( \mu_n \) to verify it is close to \( \mu \) and plot your mean centered data to verify it is centered at the origin! Compare your code with the functionality from Scikit-Learn discussed above. @@ -254,7 +254,7 @@ centered at the origin! Compare your code with the functionality from Scikit- Now we are going to use the mean centered data to compute the sample covariance of the data. Recall it is given by: $$ \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) +\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) \end{equation*} $$ @@ -265,9 +265,9 @@ Compare the computed covariance with the answer given above.

Now we are ready to solve for the principal components! To do so we -diagonalize the sample covariance matrix \( \Sigma_N \). We can use the +diagonalize the sample covariance matrix \( \Sigma_n \). We can use the function np.linalg.eig to do so. It will return the eigenvalues and -eigenvectors of \( \Sigma_N \). Once you have these, carry out the +eigenvectors of \( \Sigma_n \). Once you have these, carry out the following tasks: