| 1 | <html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 2 | <title>PCA & PCA: Get angle between pc1-pc2 planes</title> |
| 3 | <style> |
| 4 | td { padding-left: 5pt; padding-right: 5pt; } |
| 5 | th { padding-left: 5pt; padding-right: 5pt; } |
| 6 | code { white-space: pre-wrap; } |
| 7 | dd { white-space: pre-wrap; } |
| 8 | </style> |
| 9 | </head><body bgcolor="#FFFFFF"> |
| 10 | |
| 11 | <table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCC00"><table border=4 cellpadding=9><tr><td align=middle bgcolor="#000000"><font face="Palatino,Times" size=6 color="#999900"><b> |
| 12 | PCA & PCA: Get angle between pc1-pc2 planes |
| 13 | </b></font></table></table> |
| 14 | <p>A command to calculate the angle between two planes. Each plane is spanned by the first two eigenvectors from the corresponding <a href="PCA.html">PCA</a>.</p> |
| 15 | <h2>Algorithm</h2> |
| 16 | <p>The algorithm is described in section 12.4.3 of <a href="Golub___van_Loan__1996_.html">Golub & van Loan (1996)</a>:</p> |
| 17 | <p>First we form the projection of one set of eigenvectors on the other set. This results in a 2×2 matrix <b>C</b>:</p> |
| 18 | <table width="100%" style="white-space:pre-wrap"><tr><td align=middle><b>C</b> = <b>E</b><sub>1</sub>′ <b>E</b><sub>2</sub>,</table> |
| 19 | <p>where <b>E</b><sub>1</sub> and <b>E</b><sub>2</sub> are 2×<i>dimension</i> and <i>dimension</i>×2 matrices that contain the first two eigenvectors of the PCA's, respectively.</p> |
| 20 | <p>Next, we compute the <a href="singular_value_decomposition.html">singular value decomposition</a> of <b>C</b>:</p> |
| 21 | <table width="100%" style="white-space:pre-wrap"><tr><td align=middle><b>C</b> = <b>U</b> <b>D</b> <b>V</b>′</table> |
| 22 | <p>Now the cosine of the angle between the two planes is given by the second singular value σ<sub>2</sub> and the angle in degrees is therefore:</p> |
| 23 | <table width="100%" style="white-space:pre-wrap"><tr><td align=middle>arccos (σ<sub>2</sub>)·180/π</table> |
| 24 | <hr> |
| 25 | <address> |
| 26 | <p>© djmw 20220111</p> |
| 27 | </address> |
| 28 | </body> |
| 29 | </html> |