Skip to content

Commit

Permalink
pca2 edits
Browse files Browse the repository at this point in the history
  • Loading branch information
lillianw101 committed Apr 18, 2024
1 parent 34b0b20 commit 15c1ad6
Show file tree
Hide file tree
Showing 14 changed files with 307 additions and 156 deletions.
Binary file added pca_1/images/optimization_takeaways.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions pca_1/pca_1.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,11 @@ $$\begin{aligned}

This result implies that:

* $w$ is a **unitary eigenvector** of the covariance matrix.
* $w$ is a **unitary eigenvector** of the covariance matrix. This means that $||w||^2 = ww^T = 1$
* The error is minimized when $w$ is the eigenvector with the largest eigenvalue $\lambda$.

This derivation can inductively be used for the next (second) principal component (not shown).

The final takeaway from this derivation is that the **principal components** are the **eigenvectors** with the **largest eigenvalues** of the **covariance matrix**. These are the **directions** of the **maximum variance** of the data.
The final takeaway from this derivation is that the **principal components** are the **eigenvectors** with the **largest eigenvalues** of the **covariance matrix**. These are the **directions** of the **maximum variance** of the data. We can construct the **latent factors (the Z matrix)** by **projecting** the centered data X onto the principal component vectors:

<center><img src = "images/optimization_takeaways.png" width="450vw"></center>
101 changes: 101 additions & 0 deletions pca_2/data/rectangle_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
width,height,area,perimeter
8,6,48,28
2,4,8,12
1,3,3,8
9,3,27,24
9,8,72,34
3,1,3,8
4,2,8,12
6,5,30,22
7,1,7,16
8,2,16,20
5,5,25,20
9,5,45,28
8,4,32,24
1,2,2,6
2,9,18,22
7,8,56,30
7,5,35,24
2,4,8,12
2,5,10,14
4,3,12,14
8,1,8,18
8,5,40,26
9,8,72,34
7,3,21,20
8,3,24,22
6,6,36,24
6,4,24,20
8,4,32,24
7,2,14,18
4,4,16,16
4,1,4,10
9,7,63,32
4,2,8,12
1,2,2,6
8,1,8,18
5,4,20,18
9,5,45,28
6,9,54,30
3,7,21,20
7,3,21,20
7,7,49,28
3,3,9,12
5,5,25,20
7,3,21,20
8,2,16,20
2,6,12,16
7,1,7,16
1,2,2,6
3,5,15,16
2,6,12,16
5,6,30,22
9,1,9,20
6,3,18,18
2,6,12,16
6,8,48,28
9,1,9,20
2,8,16,20
3,7,21,20
6,5,30,22
8,6,48,28
9,2,18,22
3,9,27,24
2,5,10,14
1,4,4,10
3,3,9,12
2,9,18,22
6,4,24,20
5,2,10,14
2,6,12,16
2,5,10,14
1,3,3,8
1,3,3,8
6,7,42,26
8,6,48,28
2,7,14,18
4,6,24,20
1,1,1,4
9,8,72,34
5,5,25,20
3,9,27,24
2,8,16,20
2,2,4,8
8,3,24,22
1,8,8,18
5,1,5,12
5,7,35,24
9,5,45,28
3,1,3,8
9,7,63,32
8,5,40,26
9,8,72,34
4,5,20,18
4,5,20,18
1,5,5,12
6,6,36,24
8,5,40,26
8,7,56,30
1,4,4,10
1,6,6,14
2,6,12,16
Binary file added pca_2/images/Z.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added pca_2/images/s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
353 changes: 200 additions & 153 deletions pca_2/pca_2.qmd

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion probability_1/probability_1.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,9 @@ $$ \begin{align}
:::

### Covariance and Correlation
We define the **covariance** of two random variables as the expected product of deviations from expectation. Put more simply, covariance is a generalization of variance to variance: $\text{Cov}(X, X) = \mathbb{E}[(X - \mathbb{E}[X])^2] = \text{Var}(X)$
We define the **covariance** of two random variables as the expected product of deviations from expectation. Put more simply, covariance is a generalization of variance to variance:

$$\text{Cov}(X, X) = \mathbb{E}[(X - \mathbb{E}[X])^2] = \text{Var}(X)$$

$$\text{Cov}(X, Y) = \mathbb{E}[(X - \mathbb{E}[X])(Y - \mathbb{E}[Y])]$$

Expand Down

0 comments on commit 15c1ad6

Please sign in to comment.