<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Computer vision for dummies &#187; Eigenvectors</title>
	<atom:link href="https://www.visiondummy.com/tag/eigenvectors/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.visiondummy.com</link>
	<description>A blog about intelligent algorithms, machine learning, computer vision, datamining and more.</description>
	<lastBuildDate>Tue, 04 May 2021 14:17:31 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.8.39</generator>
	<item>
		<title>Feature extraction using PCA</title>
		<link>https://www.visiondummy.com/2014/05/feature-extraction-using-pca/</link>
		<comments>https://www.visiondummy.com/2014/05/feature-extraction-using-pca/#comments</comments>
		<pubDate>Fri, 16 May 2014 09:33:27 +0000</pubDate>
		<dc:creator><![CDATA[Vincent Spruyt]]></dc:creator>
				<category><![CDATA[Feature extraction]]></category>
		<category><![CDATA[dimensionality reduction]]></category>
		<category><![CDATA[Eigenvectors]]></category>
		<category><![CDATA[feature extraction]]></category>
		<category><![CDATA[LDA]]></category>
		<category><![CDATA[Matlab]]></category>
		<category><![CDATA[PCA]]></category>
		<category><![CDATA[Principal Component Analysis]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://www.visiondummy.com/?p=328</guid>
		<description><![CDATA[<p>In this article, we discuss how Principal Component Analysis (PCA) works, and how it can be used as a dimensionality reduction technique for classification problems. At the end of this article, Matlab source code is provided for demonstration purposes. In an earlier article, we discussed the so called Curse of Dimensionality and showed that classifiers [...]</p>
<p>The post <a rel="nofollow" href="https://www.visiondummy.com/2014/05/feature-extraction-using-pca/">Feature extraction using PCA</a> appeared first on <a rel="nofollow" href="https://www.visiondummy.com">Computer vision for dummies</a>.</p>
]]></description>
				<content:encoded><![CDATA[<h2>Introduction</h2>
<p>In this article, we discuss how Principal Component Analysis (PCA) works, and how it can be used as a dimensionality reduction technique for classification problems. At the end of this article,  Matlab source code is provided for demonstration purposes.</p>
<p>In an earlier article, we discussed the so called <a title="The Curse of Dimensionality in classification" href="http://www.visiondummy.com/2014/04/curse-dimensionality-affect-classification/" target="_blank">Curse of Dimensionality</a> and showed that classifiers tend to overfit the training data in high dimensional spaces. The question then rises which features should be preferred and which ones should be removed from a high dimensional feature vector.</p>
<p>If all features in this feature vector were statistically independent, one could simply eliminate the least discriminative features from this vector. The least discriminative features can be found by various greedy <a title="Feature Selection" href="https://en.wikipedia.org/wiki/Feature_selection" target="_blank">feature selection</a> approaches. However, in practice, many features depend on each other or on an underlying unknown variable. A single feature could therefore represent a combination of multiple types of information by a single value. Removing such a feature would remove more information than needed. In the next paragraphs, we introduce PCA as a <a title="Feature Extraction" href="https://en.wikipedia.org/wiki/Feature_extraction" target="_blank">feature extraction</a> solution to this problem, and introduce its inner workings from two different perspectives.</p>
<h2>PCA as a decorrelation method</h2>
<p>More often than not, features are correlated. As an example, consider the case where we want to use the red, green and blue components of each pixel in an image to classify the image (e.g. detect dogs versus cats). Image sensors that are most sensitive to red light also capture some blue and green light. Similarly, sensors that are most sensitive to blue and green light also exhibit a certain degree of sensitivity to red light. As a result, the R, G, B components of a pixel are statistically correlated. Therefore, simply eliminating the R component from the feature vector, also implicitly removes information about the G and B channels. In other words, before eliminating features, we would like to transform the complete feature space such that the underlying uncorrelated components are obtained.</p>
<p>Consider the following example of a 2D feature space:</p>
<div id="attachment_484" style="width: 391px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/05/correlated_2d.png"><img class="size-full wp-image-484 " style="margin: 0px;" title="2D Correlated data" alt="2D Correlated data" src="http://www.visiondummy.com/wp-content/uploads/2014/05/correlated_2d.png" width="381" height="369" /></a><p class="wp-caption-text"><b>Figure 1</b> 2D Correlated data with eigenvectors shown in color.</p></div>
<p>The features <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-4ec8d3fee12d10b3855b33535cb75c7e_l3.png" class="ql-img-inline-formula " alt="&#120;" title="Rendered by QuickLaTeX.com" height="9" width="12" style="vertical-align: 0px;"/> and <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-45a49b291744d497b47a3c22cff46118_l3.png" class="ql-img-inline-formula " alt="&#121;" title="Rendered by QuickLaTeX.com" height="13" width="11" style="vertical-align: -4px;"/>, illustrated by figure 1, are clearly correlated. In fact, their covariance matrix is:</p>
<p class="ql-center-displayed-equation" style="line-height: 64px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-14c617ab0933f92980b8be162cbd2e52_l3.png" height="64" width="176" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#83;&#105;&#103;&#109;&#97;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#49;&#54;&#46;&#56;&#55;&#32;&#38;&#32;&#49;&#52;&#46;&#57;&#52;&#32;&#92;&#92;&#091;&#48;&#46;&#51;&#101;&#109;&#093; &#49;&#52;&#46;&#57;&#52;&#32;&#38;&#32;&#49;&#55;&#46;&#50;&#55;&#32;&#92;&#92;&#091;&#48;&#46;&#51;&#101;&#109;&#093; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>In an earlier article we discussed the <a title="A geometric interpretation of the covariance matrix" href="http://www.visiondummy.com/2014/04/geometric-interpretation-covariance-matrix/" target="_blank">geometric interpretation of the covariance matrix</a>. We saw that the covariance matrix can be decomposed as a sequence of rotation and scaling operations on white, uncorrelated data, where the rotation matrix is defined by the <a title="What are eigenvectors and eigenvalues?" href="http://www.visiondummy.com/2014/03/eigenvalues-eigenvectors/" target="_blank">eigenvectors</a> of this covariance matrix. Therefore, intuitively, it is easy to see that the data <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-6fe012cfdbc6f342dbd886ff568ed4ab_l3.png" class="ql-img-inline-formula " alt="&#68;" title="Rendered by QuickLaTeX.com" height="14" width="17" style="vertical-align: 0px;"/> shown in figure 1 can be decorrelated by rotating each data point such that the eigenvectors <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-1f1ceff6690e6ea05bc7802220277816_l3.png" class="ql-img-inline-formula " alt="&#86;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/> become the new reference axes:</p>
<p class="ql-center-displayed-equation" style="line-height: 18px;"><span class="ql-right-eqno"> (1) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-cd9ddfd02d4554c9af5ad59e303197d7_l3.png" height="18" width="89" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#68;&#39;&#32;&#61;&#32;&#86;&#32;&#92;&#44;&#32;&#68; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<div id="attachment_486" style="width: 370px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/05/uncorrelated_2d.png"><img class="size-full wp-image-486 " style="margin-left: 0px; margin-right: 0px;" title="2D Uncorrelated data with eigenvectors shown in color." alt="2D Uncorrelated data with eigenvectors shown in color." src="http://www.visiondummy.com/wp-content/uploads/2014/05/uncorrelated_2d.png" width="360" height="352" /></a><p class="wp-caption-text"><b>Figure 2.</b>2D Uncorrelated data with eigenvectors shown in color.</p></div>
<p>The covariance matrix of the resulting data is now diagonal, meaning that the new axes are uncorrelated:</p>
<p class="ql-center-displayed-equation" style="line-height: 64px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-47a3fd2d5bf71c6b0cc423f4f2bddacd_l3.png" height="64" width="161" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#83;&#105;&#103;&#109;&#97;&#39;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#49;&#46;&#48;&#54;&#32;&#38;&#32;&#48;&#46;&#48;&#32;&#92;&#92;&#091;&#48;&#46;&#51;&#101;&#109;&#093; &#48;&#46;&#48;&#32;&#38;&#32;&#49;&#54;&#46;&#48;&#32;&#92;&#92;&#091;&#48;&#46;&#51;&#101;&#109;&#093; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>In fact, the original data used in this example and shown by figure 1 was generated by linearly combining two 1D Gaussian feature vectors <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-1cadfeede5cda580c034e24f4d265543_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#49;&#32;&#92;&#115;&#105;&#109;&#32;&#78;&#40;&#48;&#44;&#32;&#49;&#41;" title="Rendered by QuickLaTeX.com" height="23" width="115" style="vertical-align: -6px;"/> and <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-7bb939fc06c0f246ceb69c88a7531f13_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#50;&#32;&#92;&#115;&#105;&#109;&#32;&#78;&#40;&#48;&#44;&#32;&#49;&#41;" title="Rendered by QuickLaTeX.com" height="23" width="115" style="vertical-align: -6px;"/> as follows:</p>
<p class="ql-center-displayed-equation" style="line-height: 49px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-44352278d27d065a48a38b001172bb96_l3.png" height="49" width="106" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#120;&#32;&#38;&#61;&#32;&#120;&#95;&#50;&#32;&#43;&#32;&#120;&#95;&#49;&#92;&#92; &#121;&#32;&#38;&#61;&#32;&#120;&#95;&#50;&#32;&#45;&#32;&#120;&#95;&#49; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Since the features <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-4ec8d3fee12d10b3855b33535cb75c7e_l3.png" class="ql-img-inline-formula " alt="&#120;" title="Rendered by QuickLaTeX.com" height="9" width="12" style="vertical-align: 0px;"/> and <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-45a49b291744d497b47a3c22cff46118_l3.png" class="ql-img-inline-formula " alt="&#121;" title="Rendered by QuickLaTeX.com" height="13" width="11" style="vertical-align: -4px;"/> are linear combinations of some unknown underlying components <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-10f41adc642c8c760433cce6b61ef4e5_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#49;" title="Rendered by QuickLaTeX.com" height="13" width="19" style="vertical-align: -4px;"/> and <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-d524564df7bc7677587255e0f12bb1ea_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#50;" title="Rendered by QuickLaTeX.com" height="12" width="20" style="vertical-align: -3px;"/>, directly eliminating either <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-4ec8d3fee12d10b3855b33535cb75c7e_l3.png" class="ql-img-inline-formula " alt="&#120;" title="Rendered by QuickLaTeX.com" height="9" width="12" style="vertical-align: 0px;"/> or <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-45a49b291744d497b47a3c22cff46118_l3.png" class="ql-img-inline-formula " alt="&#121;" title="Rendered by QuickLaTeX.com" height="13" width="11" style="vertical-align: -4px;"/> as a feature would have removed some information from both <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-10f41adc642c8c760433cce6b61ef4e5_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#49;" title="Rendered by QuickLaTeX.com" height="13" width="19" style="vertical-align: -4px;"/> and <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-d524564df7bc7677587255e0f12bb1ea_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#50;" title="Rendered by QuickLaTeX.com" height="12" width="20" style="vertical-align: -3px;"/>. Instead, rotating the data by the eigenvectors of its covariance matrix, allowed us to directly recover the independent components <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-10f41adc642c8c760433cce6b61ef4e5_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#49;" title="Rendered by QuickLaTeX.com" height="13" width="19" style="vertical-align: -4px;"/> and <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-d524564df7bc7677587255e0f12bb1ea_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#50;" title="Rendered by QuickLaTeX.com" height="12" width="20" style="vertical-align: -3px;"/> (up to a scaling factor). This can be seen as follows: The eigenvectors of the covariance matrix of the original data are (each column represents an eigenvector):</p>
<p class="ql-center-displayed-equation" style="line-height: 64px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-5118e8d82d044ca6a8c48a62c8e8659b_l3.png" height="64" width="216" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#86;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#45;&#48;&#46;&#55;&#48;&#55;&#49;&#32;&#38;&#32;&#48;&#46;&#55;&#48;&#55;&#49;&#32;&#92;&#92;&#091;&#48;&#46;&#51;&#101;&#109;&#093; &#48;&#46;&#55;&#48;&#55;&#49;&#32;&#38;&#32;&#48;&#46;&#55;&#48;&#55;&#49;&#32;&#92;&#92;&#091;&#48;&#46;&#51;&#101;&#109;&#093; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>The first thing to notice is that <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-1f1ceff6690e6ea05bc7802220277816_l3.png" class="ql-img-inline-formula " alt="&#86;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/> in this case is a rotation matrix, corresponding to a rotation of 45 degrees (cos(45)=0.7071), which indeed is evident from figure 1. Secondly, treating <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-1f1ceff6690e6ea05bc7802220277816_l3.png" class="ql-img-inline-formula " alt="&#86;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/> as a linear transformation matrix results in a new coordinate system, such that each new feature <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-a9028279d9163c7ddd6df95bc95d2f6e_l3.png" class="ql-img-inline-formula " alt="&#120;&#39;" title="Rendered by QuickLaTeX.com" height="17" width="17" style="vertical-align: 0px;"/> and <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-64b88bf8f73f94697796573e352ce2ce_l3.png" class="ql-img-inline-formula " alt="&#121;&#39;" title="Rendered by QuickLaTeX.com" height="21" width="16" style="vertical-align: -4px;"/> is expressed as a linear combination of the original features <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-4ec8d3fee12d10b3855b33535cb75c7e_l3.png" class="ql-img-inline-formula " alt="&#120;" title="Rendered by QuickLaTeX.com" height="9" width="12" style="vertical-align: 0px;"/> and <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-45a49b291744d497b47a3c22cff46118_l3.png" class="ql-img-inline-formula " alt="&#121;" title="Rendered by QuickLaTeX.com" height="13" width="11" style="vertical-align: -4px;"/>:</p>
<p class="ql-center-displayed-equation" style="line-height: 86px;"><span class="ql-right-eqno"> (2) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-4bef74cbe5562913a85bffd0e9bf98f4_l3.png" height="86" width="379" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#120;&#39;&#32;&#38;&#61;&#32;&#45;&#48;&#46;&#55;&#48;&#55;&#49;&#32;&#92;&#44;&#32;&#120;&#32;&#43;&#32;&#48;&#46;&#55;&#48;&#55;&#49;&#32;&#121;&#32;&#92;&#92; &#38;&#61;&#32;&#45;&#48;&#46;&#55;&#48;&#55;&#49;&#32;&#92;&#44;&#32;&#40;&#120;&#95;&#50;&#32;&#43;&#32;&#120;&#95;&#49;&#41;&#32;&#43;&#32;&#48;&#46;&#55;&#48;&#55;&#49;&#32;&#92;&#44;&#32;&#40;&#120;&#95;&#50;&#32;&#45;&#32;&#120;&#95;&#49;&#41;&#32;&#92;&#92; &#38;&#61;&#32;&#45;&#49;&#46;&#52;&#49;&#52;&#50;&#32;&#92;&#44;&#32;&#120;&#95;&#49; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>and</p>
<p class="ql-center-displayed-equation" style="line-height: 85px;"><span class="ql-right-eqno"> (3) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-ba4842d96a50e3b54f3ef2580f67cf6e_l3.png" height="85" width="374" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#121;&#39;&#32;&#38;&#61;&#32;&#48;&#46;&#55;&#48;&#55;&#49;&#32;&#92;&#44;&#32;&#120;&#32;&#43;&#32;&#48;&#46;&#55;&#48;&#55;&#49;&#32;&#121;&#32;&#92;&#92; &#38;&#61;&#32;&#48;&#46;&#55;&#48;&#55;&#49;&#32;&#92;&#44;&#32;&#40;&#120;&#95;&#50;&#32;&#43;&#32;&#120;&#95;&#49;&#41;&#32;&#43;&#32;&#48;&#46;&#55;&#48;&#55;&#49;&#32;&#92;&#44;&#32;&#40;&#120;&#95;&#50;&#32;&#45;&#32;&#120;&#95;&#49;&#41;&#32;&#121;&#32;&#92;&#92; &#38;&#61;&#32;&#49;&#46;&#52;&#49;&#52;&#50;&#32;&#92;&#44;&#32;&#120;&#95;&#50; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>In other words, decorrelation of the feature space corresponds to the recovery of the unknown, uncorrelated components <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-10f41adc642c8c760433cce6b61ef4e5_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#49;" title="Rendered by QuickLaTeX.com" height="13" width="19" style="vertical-align: -4px;"/> and <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-55c686b7dd9f01a22235b0fa802ee7ce_l3.png" class="ql-img-inline-formula " alt="&#121;&#95;&#49;" title="Rendered by QuickLaTeX.com" height="13" width="17" style="vertical-align: -4px;"/> of the data (up to an unknown scaling factor if the transformation matrix was not orthogonal). Once these components have been recovered, it is easy to reduce the dimensionality of the feature space by simply eliminating either <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-10f41adc642c8c760433cce6b61ef4e5_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#49;" title="Rendered by QuickLaTeX.com" height="13" width="19" style="vertical-align: -4px;"/> or <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-d524564df7bc7677587255e0f12bb1ea_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#50;" title="Rendered by QuickLaTeX.com" height="12" width="20" style="vertical-align: -3px;"/>.</p>
<p>In the above example we started with a two-dimensional problem. If we would like to reduce the dimensionality, the question remains whether to eliminate <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-10f41adc642c8c760433cce6b61ef4e5_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#49;" title="Rendered by QuickLaTeX.com" height="13" width="19" style="vertical-align: -4px;"/> (and thus <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-a9028279d9163c7ddd6df95bc95d2f6e_l3.png" class="ql-img-inline-formula " alt="&#120;&#39;" title="Rendered by QuickLaTeX.com" height="17" width="17" style="vertical-align: 0px;"/>) or <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-55c686b7dd9f01a22235b0fa802ee7ce_l3.png" class="ql-img-inline-formula " alt="&#121;&#95;&#49;" title="Rendered by QuickLaTeX.com" height="13" width="17" style="vertical-align: -4px;"/> (and thus <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-64b88bf8f73f94697796573e352ce2ce_l3.png" class="ql-img-inline-formula " alt="&#121;&#39;" title="Rendered by QuickLaTeX.com" height="21" width="16" style="vertical-align: -4px;"/>). Although this choice could depend on many factors such as the separability of the data in case of classification problems, PCA simply assumes that the most interesting feature is the one with the largest variance or spread. This assumption is based on an information theoretic point of view, since the dimension with the largest variance corresponds to the dimension with the largest entropy and thus encodes the most information. The smallest eigenvectors will often simply represent noise components, whereas the largest eigenvectors often correspond to the principal components that define the data.</p>
<p>Dimensionality reduction by means of PCA is then accomplished simply by projecting the data onto the largest eigenvectors of its covariance matrix. For the above example, the resulting 1D feature space is illustrated by figure 3:</p>
<div id="attachment_504" style="width: 366px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/05/uncorrelated_1d.png"><img class="size-full wp-image-504" style="margin: 0px;" title="2D data projected onto its largest eigenvector" alt="2D data projected onto its largest eigenvector" src="http://www.visiondummy.com/wp-content/uploads/2014/05/uncorrelated_1d.png" width="356" height="352" /></a><p class="wp-caption-text"><b>Figure 3.</b> PCA: 2D data projected onto its largest eigenvector.</p></div>
<p>Obivously, the above example easily generalizes to higher dimensional feature spaces. For instance, in the three-dimensional case, we can either project the data onto the plane defined by the two largest eigenvectors to obtain a 2D feature space, or we can project it onto the largest eigenvector to obtain a 1D feature space. This is illustrated by figure 4:</p>
<div id="attachment_513" style="width: 828px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/05/PCA_3d.png"><img class="size-full wp-image-513 " style="margin: 0px;" title="Principal Component Analysis for 3D data" alt="Principal Component Analysis for 3D data" src="http://www.visiondummy.com/wp-content/uploads/2014/05/PCA_3d.png" width="818" height="751" /></a><p class="wp-caption-text"><b>Figure 4.</b> 3D data projected onto a 2D or 1D linear subspace by means of Principal Component Analysis.</p></div>
<p>In general, PCA allows us to obtain a linear M-dimensional subspace of the original N-dimensional data, where <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-62a47b6b009b99b13a43e1f68bba689d_l3.png" class="ql-img-inline-formula " alt="&#77;&#32;&#92;&#108;&#101;&#32;&#78;" title="Rendered by QuickLaTeX.com" height="17" width="70" style="vertical-align: -3px;"/>. Furthermore, if the unknown, uncorrelated components are Gaussian distributed, then PCA actually acts as an <a title="Independent Component Analysis" href="https://en.wikipedia.org/wiki/Independent_component_analysis" target="_blank">independent component analysis</a> since uncorrelated Gaussian variables are statistically independent. However, if the underlying components are not normally distributed, PCA merely generates decorrelated variables which are not necessarily statistically independent. In this case, non-linear dimensionality reduction algorithms might be a better choice.</p>
<h2>PCA as an orthogonal regression method</h2>
<p>In the above discussion, we started with the goal of obtaining independent components (or at least uncorrelated components if the data is not normally distributed) to reduce the dimensionality of the feature space. We found that these so called &#8216;principal components&#8217; are obtained by the eigendecomposition of the covariance matrix of our data. The dimensionality is then reduced by projecting the data onto the largest eigenvectors.</p>
<p>Now let&#8217;s forget about our wish to find uncorrelated components for a while. Instead, we will now try to reduce the dimensionality by finding a linear subspace of the original feature space onto which we can project our data such that the projection error is minimized. In the 2D case, this means that we try to find a vector such that projecting the data onto this vector corresponds to a projection error that is lower than the projection error that would be obtained when projecting the data onto any other possible vector. The question is then how to find this optimal vector.</p>
<p>Consider the example shown by figure 5. Three different projection vectors are shown, together with the resulting 1D data. In the next paragraphs, we will discuss how to determine which projection vector minimizes the projection error. Before searching for a vector that minimizes the projection error, we have to define this error function.</p>
<div id="attachment_520" style="width: 763px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/05/projectionvectors.png"><img class="size-full wp-image-520 " style="margin: 0px;" title="Dimensionality reduction by projection onto a linear subspace" alt="Dimensionality reduction by projection onto a linear subspace" src="http://www.visiondummy.com/wp-content/uploads/2014/05/projectionvectors.png" width="753" height="838" /></a><p class="wp-caption-text"><b>Figure 5</b> Dimensionality reduction by projection onto a linear subspace</p></div>
<p>A well known method to fit a line to 2D data is <a title="Least squares regression" href="https://en.wikipedia.org/wiki/Least_squares" target="_blank">least squares regression</a>. Given the independent variable <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-4ec8d3fee12d10b3855b33535cb75c7e_l3.png" class="ql-img-inline-formula " alt="&#120;" title="Rendered by QuickLaTeX.com" height="9" width="12" style="vertical-align: 0px;"/> and the dependent variable <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-45a49b291744d497b47a3c22cff46118_l3.png" class="ql-img-inline-formula " alt="&#121;" title="Rendered by QuickLaTeX.com" height="13" width="11" style="vertical-align: -4px;"/>, the least squares regressor corresponds to the line <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-6021228e108e47f32c04ed00e60802c3_l3.png" class="ql-img-inline-formula " alt="&#102;&#40;&#120;&#41;&#32;&#61;&#32;&#97;&#120;&#32;&#43;&#32;&#98;" title="Rendered by QuickLaTeX.com" height="23" width="126" style="vertical-align: -6px;"/>, such that the sum of the squared residual errors <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-47711a352bd88c1a022c83777f6b5fb6_l3.png" class="ql-img-inline-formula " alt="&#92;&#115;&#117;&#109;&#95;&#123;&#105;&#61;&#48;&#125;&#94;&#78;&#32;&#40;&#102;&#40;&#120;&#95;&#105;&#41;&#32;&#45;&#32;&#121;&#95;&#105;&#41;&#94;&#50;" title="Rendered by QuickLaTeX.com" height="27" width="163" style="vertical-align: -6px;"/> is minimized. In other words, if <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-4ec8d3fee12d10b3855b33535cb75c7e_l3.png" class="ql-img-inline-formula " alt="&#120;" title="Rendered by QuickLaTeX.com" height="9" width="12" style="vertical-align: 0px;"/> is treated as the independent variable, then the obtained regressor <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-8203ebb370a40451e2ce0a21cd8a84ed_l3.png" class="ql-img-inline-formula " alt="&#102;&#40;&#120;&#41;" title="Rendered by QuickLaTeX.com" height="23" width="39" style="vertical-align: -6px;"/> is a linear function that can predict the dependent variable <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-45a49b291744d497b47a3c22cff46118_l3.png" class="ql-img-inline-formula " alt="&#121;" title="Rendered by QuickLaTeX.com" height="13" width="11" style="vertical-align: -4px;"/> such that the squared error is minimal. The resulting model <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-8203ebb370a40451e2ce0a21cd8a84ed_l3.png" class="ql-img-inline-formula " alt="&#102;&#40;&#120;&#41;" title="Rendered by QuickLaTeX.com" height="23" width="39" style="vertical-align: -6px;"/> is illustrated by the blue line in figure 5, and the error that is minimized is illustrated in figure 6.</p>
<div id="attachment_525" style="width: 398px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/05/y_regression.png"><img class="size-full wp-image-525" style="margin: 0px;" title="Linear regression with x as the independent variable" alt="Linear regression with x as the independent variable" src="http://www.visiondummy.com/wp-content/uploads/2014/05/y_regression.png" width="388" height="364" /></a><p class="wp-caption-text"><b>Figure 6.</b> Linear regression where x is the independent variable and y is the dependent variable, corresponds to minimizing the vertical projection error.</p></div>
<p>However, in the context of feature extraction, one might wonder why we would define feature <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-4ec8d3fee12d10b3855b33535cb75c7e_l3.png" class="ql-img-inline-formula " alt="&#120;" title="Rendered by QuickLaTeX.com" height="9" width="12" style="vertical-align: 0px;"/> as the independent variable and feature <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-45a49b291744d497b47a3c22cff46118_l3.png" class="ql-img-inline-formula " alt="&#121;" title="Rendered by QuickLaTeX.com" height="13" width="11" style="vertical-align: -4px;"/> as the dependent variable. In fact, we could easily define <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-45a49b291744d497b47a3c22cff46118_l3.png" class="ql-img-inline-formula " alt="&#121;" title="Rendered by QuickLaTeX.com" height="13" width="11" style="vertical-align: -4px;"/> as the independent variable and find a linear function <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-450f14ad81fe58cc3fadbd3b26902e61_l3.png" class="ql-img-inline-formula " alt="&#102;&#40;&#121;&#41;" title="Rendered by QuickLaTeX.com" height="23" width="38" style="vertical-align: -6px;"/> that predicts the dependent variable <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-4ec8d3fee12d10b3855b33535cb75c7e_l3.png" class="ql-img-inline-formula " alt="&#120;" title="Rendered by QuickLaTeX.com" height="9" width="12" style="vertical-align: 0px;"/>, such that <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-9e0ddca31e33403036539470779b955f_l3.png" class="ql-img-inline-formula " alt="&#92;&#115;&#117;&#109;&#95;&#123;&#105;&#61;&#48;&#125;&#94;&#78;&#32;&#40;&#102;&#40;&#121;&#95;&#105;&#41;&#32;&#45;&#32;&#120;&#95;&#105;&#41;&#94;&#50;" title="Rendered by QuickLaTeX.com" height="27" width="163" style="vertical-align: -6px;"/> is minimized. This corresponds to minimization of the horizontal projection error and results in a different linear model as shown by figure 7:</p>
<div id="attachment_527" style="width: 385px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/05/x_regression.png"><img class="size-full wp-image-527" style="margin: 0px;" title="Linear regression with y as the independent variable" alt="Linear regression with y as the independent variable" src="http://www.visiondummy.com/wp-content/uploads/2014/05/x_regression.png" width="375" height="364" /></a><p class="wp-caption-text"><b>Figure 7.</b> Linear regression where y is the independent variable and x is the dependent variable, corresponds to minimizing the horizontal projection error.</p></div>
<p>Clearly, the choice of independent and dependent variables changes the resulting model, making ordinary least squares regression an asymmetric regressor. The reason for this is that least squares regression assumes the independent variable to be noise-free, whereas the dependent variable is assumed to be noisy. However, in the case of classification, all features are usually noisy observations such that neither <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-4ec8d3fee12d10b3855b33535cb75c7e_l3.png" class="ql-img-inline-formula " alt="&#120;" title="Rendered by QuickLaTeX.com" height="9" width="12" style="vertical-align: 0px;"/> or <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-45a49b291744d497b47a3c22cff46118_l3.png" class="ql-img-inline-formula " alt="&#121;" title="Rendered by QuickLaTeX.com" height="13" width="11" style="vertical-align: -4px;"/> should be treated as independent. In fact, we would like to obtain a model <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-ad076ce94ed0bb6e7c3cd425c6a47709_l3.png" class="ql-img-inline-formula " alt="&#102;&#40;&#120;&#44;&#121;&#41;" title="Rendered by QuickLaTeX.com" height="23" width="59" style="vertical-align: -6px;"/> that minimizes both the horizontal and the vertical projection error simultaneously. This corresponds to finding a model such that the orthogonal projection error is minimized as shown by figure 8.</p>
<div id="attachment_529" style="width: 405px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/05/xy_regression.png"><img class="size-full wp-image-529" style="margin: 0px;" title="Linear regression where both variables are independent" alt="Linear regression where both variables are independent" src="http://www.visiondummy.com/wp-content/uploads/2014/05/xy_regression.png" width="395" height="369" /></a><p class="wp-caption-text"><b>Figure 8.</b> Linear regression where both variables are independent corresponds to minimizing the orthogonal projection error.</p></div>
<p>The resulting regression is called <a title="Total Least Squares regression" href="https://en.wikipedia.org/wiki/Total_least_squares" target="_blank">Total Least Squares regression</a> or orthogonal regression, and assumes that both variables are imperfect observations. An interesting observation is now that the obtained vector, representing the projection direction that minimizes the orthogonal projection error, corresponds the the largest principal component of the data:</p>
<div id="attachment_531" style="width: 392px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/05/regressionline_eigenvector.png"><img class="size-full wp-image-531" style="margin: 0px;" title="Orthogonal regression based on eigendecomposition" alt="Orthogonal regression based on eigendecomposition" src="http://www.visiondummy.com/wp-content/uploads/2014/05/regressionline_eigenvector.png" width="382" height="369" /></a><p class="wp-caption-text"><b>Figure 9.</b> The vector which the data can be projected unto with minimal orthogonal error corresponds to the largest eigenvector of the covariance matrix of the data.</p></div>
<p>In other words, if we want to reduce the dimensionality by projecting the original data onto a vector such that the squared projection error is minimized in all directions, we can simply project the data onto the largest eigenvectors. This is exactly what we called Principal Component Analysis in the previous section, where we showed that such projection also decorrelates the feature space.</p>
<h2>A practical PCA application: Eigenfaces</h2>
<p>Although the above examples are limited to two or three dimensions for visualization purposes, dimensionality reduction usually becomes important when the number of features is not negligible compared to the number of training samples. As an example, suppose we would like to perform face recognition, i.e. determine the identity of the person depicted in an image, based on a training dataset of labeled face images. One approach might be to treat the brightness of each pixel of the image as a feature. If the input images are of size 32&#215;32 pixels, this means that the feature vector contains 1024 feature values. Classifying a new face image can then be done by calculating the Euclidean distance between this 1024-dimensional vector, and the feature vectors of the people in our training dataset. The smallest distance then tells us which person we are looking at.</p>
<p>However, operating in a 1024-dimensional space becomes problematic if we only have a few hundred training samples. Furthermore, Euclidean distances behave strangely in high dimensional spaces as discussed in <a title="The Curse of Dimensionality in classification" href="http://www.visiondummy.com/2014/04/curse-dimensionality-affect-classification/" target="_blank">an earlier article</a>. Therefore, we could use PCA to reduce the dimensionality of the feature space by calculating the eigenvectors of the covariance matrix of the set of 1024-dimensional feature vectors, and then projecting each feature vector onto the largest eigenvectors.</p>
<p>Since the eigenvector of 2D data is 2-dimensional, and an eigenvector of 3D data is 3-dimensional, the eigenvectors of 1024-dimensional data is 1024-dimensional. In other words, we could reshape each of the 1024-dimensional eigenvectors to a 32&#215;32 image for visualization purposes. Figure 10 shows the first four eigenvectors obtained by eigendecomposition of the <a title="Cambridge face dataset" href="http://www.cl.cam.ac.uk/research/dtg/attarchive/facedatabase.html" target="_blank">Cambridge face dataset</a>:</p>
<div id="attachment_535" style="width: 367px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/05/Eigenfaces.png"><img class="size-full wp-image-535" style="margin: 0px;" alt="Eigenfaces" src="http://www.visiondummy.com/wp-content/uploads/2014/05/Eigenfaces.png" width="357" height="426" /></a><p class="wp-caption-text"><b>Figure 10.</b> The four largest eigenvectors, reshaped to images, resulting in so called EigenFaces. (source: <a href="https://nl.wikipedia.org/wiki/Eigenface" target="_blank">https://nl.wikipedia.org/wiki/Eigenface</a>)</p></div>
<p>Each 1024-dimensional feature vector (and thus each face) can now be projected onto the N largest eigenvectors, and can be represented as a linear combination of these eigenfaces. The weights of these linear combinations determine the identity of the person. Since the largest eigenvectors represent the largest variance in the data, these eigenfaces describe the most informative image regions (eyes, noise, mouth, etc.). By only considering the first N (e.g. N=70) eigenvectors, the dimensionality of the feature space is greatly reduced.</p>
<p>The remaining question is now how many eigenfaces should be used, or in the general case; how many eigenvectors should be kept. Removing too many eigenvectors might remove important information from the feature space, whereas eliminating too few eigenvectors leaves us with the curse of dimensionality. Regrettably there is no straight answer to this problem. Although <a title="Cross Validation" href="https://en.wikipedia.org/wiki/Cross-validation_(statistics)" target="_blank">cross-validation</a> techniques can be used to obtain an estimate of this hyperparameter, choosing the optimal number of dimensions remains a problem that is mostly solved in an empirical (an academic term that means not much more than &#8216;trial-and-error&#8217;) manner. Note that it is often useful to check how much (as a percentage) of the variance of the original data is kept while eliminating eigenvectors. This is done by dividing the sum of the kept eigenvalues by the sum of all eigenvalues.</p>
<h2>The PCA recipe</h2>
<p>Based on the previous sections, we can now list the simple recipe used to apply PCA for feature extraction:</p>
<h3>1) Center the data</h3>
<p><a title="A geometric interpretation of the covariance matrix" href="http://www.visiondummy.com/2014/04/geometric-interpretation-covariance-matrix/" target="_blank">In an earlier article</a>, we showed that the covariance matrix can be written as a sequence of linear operations (scaling and rotations). The eigendecomposition extracts these transformation matrices: the eigenvectors represent the rotation matrix, while the eigenvalues represent the scaling factors. However, the covariance matrix does not contain any information related to the translation of the data. Indeed, to represent translation, an affine transformation would be needed instead of a linear transformation.</p>
<p>Therefore, before applying PCA to rotate the data in order to obtain uncorrelated axes, any existing shift needs to be countered by subtracting the mean of the data from each data point. This simply corresponds to centering the data such that its average becomes zero.</p>
<h3>2) Normalize the data</h3>
<p>The eigenvectors of the covariance matrix point in the direction of the largest variance of the data. However, variance is an absolute number, not a relative one. This means that the variance of data, measured in centimeters (or inches) will be much larger than the variance of the same data when measured in meters (or feet). Consider the example where one feature represents the length of an object in meters, while the second feature represents the width of the object in centimeters. The largest variance, and thus the largest eigenvector, will implicitly be defined by the first feature if the data is not normalized.</p>
<p>To avoid this scale-dependent nature of PCA, it is useful to normalize the data by dividing each feature by its standard deviation. This is especially important if different features correspond to different metrics.</p>
<h3>3) Calculate the eigendecomposition</h3>
<p>Since the data will be projected onto the largest eigenvectors to reduce the dimensionality, the <a title="What are eigenvectors and eigenvalues?" href="http://www.visiondummy.com/2014/03/eigenvalues-eigenvectors/" target="_blank">eigendecomposition</a> needs to be obtained. One of the most widely used methods to efficiently calculate the eigendecomposition is <a title="Singular Value Decomposition" href="https://en.wikipedia.org/wiki/Singular_value_decomposition" target="_blank">Singular Value Decomposition (SVD)</a>.</p>
<h3>4) Project the data</h3>
<p>To reduce the dimensionality, the data is simply projected onto the largest eigenvectors. Let <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-1f1ceff6690e6ea05bc7802220277816_l3.png" class="ql-img-inline-formula " alt="&#86;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/> be the matrix whose columns contain the largest eigenvectors and let <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-6fe012cfdbc6f342dbd886ff568ed4ab_l3.png" class="ql-img-inline-formula " alt="&#68;" title="Rendered by QuickLaTeX.com" height="14" width="17" style="vertical-align: 0px;"/> be the original data whose columns contain the different observations. Then the projected data <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-69e87a5558d2fcd98b5a9d1292a4345e_l3.png" class="ql-img-inline-formula " alt="&#68;&#39;" title="Rendered by QuickLaTeX.com" height="17" width="23" style="vertical-align: 0px;"/> is obtained as <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-8c1fe768ccf9dcd69f7f088075907039_l3.png" class="ql-img-inline-formula " alt="&#68;&#39;&#32;&#61;&#32;&#86;&#94;&#123;&#92;&#105;&#110;&#116;&#101;&#114;&#99;&#97;&#108;&#125;&#32;&#92;&#44;&#32;&#68;" title="Rendered by QuickLaTeX.com" height="17" width="98" style="vertical-align: 0px;"/>. We can either choose the number of remaining dimensions, i.e. the columns of <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-1f1ceff6690e6ea05bc7802220277816_l3.png" class="ql-img-inline-formula " alt="&#86;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/>, directly, or we can define the amount of variance of the original data that needs to kept while eliminating eigenvectors. If only <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-9c99ad944abf4b8313cf07a473add4bf_l3.png" class="ql-img-inline-formula " alt="&#78;" title="Rendered by QuickLaTeX.com" height="14" width="19" style="vertical-align: 0px;"/> eigenvectors are kept, and <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-fe8542b29953adbc0c9b330d17370f91_l3.png" class="ql-img-inline-formula " alt="&#101;&#95;&#49;&#46;&#46;&#46;&#101;&#95;&#78;" title="Rendered by QuickLaTeX.com" height="13" width="62" style="vertical-align: -4px;"/> represent the corresponding eigenvalues, then the amount of variance that remains after projecting the original <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-436024bdb5d181b08eb5af0204f3ca0b_l3.png" class="ql-img-inline-formula " alt="&#100;" title="Rendered by QuickLaTeX.com" height="14" width="11" style="vertical-align: 0px;"/>-dimensional data can be calculated as:</p>
<p class="ql-center-displayed-equation" style="line-height: 63px;"><span class="ql-right-eqno"> (4) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-9659a6ae2bd001ba36deb9e3e8399e05_l3.png" height="63" width="113" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#115;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#115;&#117;&#109;&#95;&#123;&#105;&#61;&#48;&#125;&#94;&#78;&#32;&#101;&#95;&#105;&#125;&#123;&#92;&#115;&#117;&#109;&#95;&#123;&#106;&#61;&#48;&#125;&#94;&#100;&#32;&#101;&#95;&#106;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<h2>PCA pitfalls</h2>
<p>In the above discussion, several assumptions have been made. In the first section, we discussed how PCA decorrelates the data. In fact, we started the discussion by expressing our desire to recover the unknown, underlying independent components of the observed features. We then assumed that our data was normally distributed, such that statistical independence simply corresponds to the lack of a linear correlation. Indeed, PCA allows us to decorrelate the data, thereby recovering the independent components in case of Gaussianity. However, it is important to note that decorrelation only corresponds to statistical independency in the Gaussian case. Consider the data obtained by sampling half a period of <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-daa28eddca8d49f4a1dab6d145eb4567_l3.png" class="ql-img-inline-formula " alt="&#121;&#61;&#115;&#105;&#110;&#40;&#120;&#41;" title="Rendered by QuickLaTeX.com" height="23" width="96" style="vertical-align: -6px;"/>:</p>
<div id="attachment_541" style="width: 384px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/05/sinx.png"><img class="size-full wp-image-541" style="margin: 0px;" alt="sinx" src="http://www.visiondummy.com/wp-content/uploads/2014/05/sinx.png" width="374" height="369" /></a><p class="wp-caption-text"><b>Figure 11</b> Uncorrelated data is only statistically independent if normally distributed. In this example a clear non-linear dependency still exists: y=sin(x).</p></div>
<p>Although the above data is clearly uncorrelated (on average, the y-value increases as much as it decreases when the x-value goes up) and therefore corresponds to a diagonal covariance matrix, there still is a clear non-linear dependency between both variables.</p>
<p>In general, PCA only uncorrelates the data but does not remove statistical dependencies. If the underlying components are known to be non-Gaussian, techniques such as <a title="Independent Component Analysis" href="https://en.wikipedia.org/wiki/Independent_component_analysis" target="_blank">ICA</a> could be more interesting. On the other hand, if non-linearities clearly exist, dimensionality reduction techniques such as <a title="Non-linear PCA" href="http://www.nlpca.org/" target="_blank">non-linear PCA</a> can be used. However, keep in mind that these methods are prone to overfitting themselves, since more parameters are to be estimated based on the same amount of training data.</p>
<p>A second assumption that was made in this article, is that the most discriminative information is captured by the largest variance in the feature space. Since the direction of the largest variance encodes the most information this is likely to be true. However, there are cases where the discriminative information actually resides in the directions of the smallest variance, such that PCA could greatly hurt classification performance. As an example, consider the two cases of figure 12, where we reduce the 2D feature space to a 1D representation:</p>
<div id="attachment_544" style="width: 587px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/05/pca_lda.png"><img class="size-full wp-image-544" style="margin: 0px;" title="PCA might hurt classification performance" alt="PCA might hurt classification performance" src="http://www.visiondummy.com/wp-content/uploads/2014/05/pca_lda.png" width="577" height="377" /></a><p class="wp-caption-text"><b>Figure 12.</b> In the first case, PCA would hurt classification performance because the data becomes linearly unseparable. This happens when the most discriminative information resides in the smaller eigenvectors.</p></div>
<p>If the most discriminative information is contained in the smaller eigenvectors, applying PCA might actually worsen the Curse of Dimensionality because now a more complicated classification model (e.g. non-linear classifier) is needed to classify the lower dimensional problem. In this case, other dimensionality reduction methods might be of interest, such as <a href="https://en.wikipedia.org/wiki/Linear_discriminant_analysis" title="Linear Discriminant Analysis" target="_blank">Linear Discriminant Analysis (LDA)</a> which tries to find the projection vector that optimally separates the two classes.</p>
<h2>Source Code</h2>
<p>The following code snippet shows how to perform principal component analysis for dimensionality reduction in Matlab:<br />
<a href="http://www.visiondummy.com/wp-content/uploads/2014/05/pca.m">Matlab source code</a></p>
<h2>Conclusion</h2>
<p>In this article, we discussed the advantages of PCA for feature extraction and dimensionality reduction from two different points of view. The first point of view explained how PCA allows us to decorrelate the feature space, whereas the second point of view showed that PCA actually corresponds to orthogonal regression.</p>
<p>Furthermore, we briefly introduced Eigenfaces as a well known example of PCA based feature extraction, and we covered some of the most important disadvantages of Principal Component Analysis.</p>
<p><strong>If you&#8217;re new to this blog, don&#8217;t forget to subscribe, or <a href="https://twitter.com/vincent_spruyt" title="Follow me on Twitter!" target="_blank">follow me on twitter</a>!</strong><br />


<!-- Form created by Optin Forms plugin by Codeleon: create beautiful optin forms with ease! -->
<!-- http://codeleon.com/products/optin-forms/ -->
<div id="optinforms-form5-container" ><form method="post" target="_blank" action="http://visiondummy.us10.list-manage.com/subscribe/post?u=c435905e10ead915f3917d694&id=bbdfb33a9f"><div id="optinforms-form5" style="background:#ffffff;"><div id="optinforms-form5-container-left"><div id="optinforms-form5-title" style="font-family:News Cycle; font-size:24px; line-height:24px; color:#fd4326">JOIN MY NEWSLETTER</div><!--optinforms-form5-title--><input type="text" id="optinforms-form5-name-field" name="FNAME" placeholder="Enter Your Name" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#000000" /><input type="text" id="optinforms-form5-email-field" name="EMAIL" placeholder="Enter Your Email" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#000000" /><input type="submit" name="submit" id="optinforms-form5-button" value="SUBSCRIBE" style="font-family:Arial, Helvetica, sans-serif; font-size:16px; color:#FFFFFF; background-color:#fd4326" /></div><!--optinforms-form5-container-left--><div id="optinforms-form5-container-right"><div id="optinforms-form5-subtitle" style="font-family:Georgia; font-size:16px; color:#444444">Receive my newsletter to get notified when new articles and code snippets become available on my blog!</div><!--optinforms-form5-subtitle--><div id="optinforms-form5-disclaimer" style="font-family:Georgia, Times New Roman, Times, serif; font-size:14px; color:#727272">We all hate spam. Your email address will not be sold or shared with anyone else.</div><!--optinforms-form5-disclaimer--></div><!--optinforms-form5-container-right--><div class="clear"></div></div><!--optinforms-form5--><div class="clear"></div></form></div><!--optinforms-form5-container--><div class="clear"></div>
<!-- / Optin Forms -->

<style type='text/css'></style></p>
<p>The post <a rel="nofollow" href="https://www.visiondummy.com/2014/05/feature-extraction-using-pca/">Feature extraction using PCA</a> appeared first on <a rel="nofollow" href="https://www.visiondummy.com">Computer vision for dummies</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.visiondummy.com/2014/05/feature-extraction-using-pca/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>A geometric interpretation of the covariance matrix</title>
		<link>https://www.visiondummy.com/2014/04/geometric-interpretation-covariance-matrix/</link>
		<comments>https://www.visiondummy.com/2014/04/geometric-interpretation-covariance-matrix/#comments</comments>
		<pubDate>Thu, 24 Apr 2014 11:09:38 +0000</pubDate>
		<dc:creator><![CDATA[Vincent Spruyt]]></dc:creator>
				<category><![CDATA[Linear algebra]]></category>
		<category><![CDATA[covariance matrix]]></category>
		<category><![CDATA[eigendecomposition]]></category>
		<category><![CDATA[Eigenvectors]]></category>
		<category><![CDATA[linear transformation]]></category>
		<category><![CDATA[PCA]]></category>

		<guid isPermaLink="false">http://www.visiondummy.com/?p=440</guid>
		<description><![CDATA[<p>In this article, we provide an intuitive, geometric interpretation of the covariance matrix, by exploring the relation between linear transformations and the resulting data covariance. Most textbooks explain the shape of data based on the concept of covariance matrices. Instead, we take a backwards approach and explain the concept of covariance matrices based on the [...]</p>
<p>The post <a rel="nofollow" href="https://www.visiondummy.com/2014/04/geometric-interpretation-covariance-matrix/">A geometric interpretation of the covariance matrix</a> appeared first on <a rel="nofollow" href="https://www.visiondummy.com">Computer vision for dummies</a>.</p>
]]></description>
				<content:encoded><![CDATA[<h2>Introduction</h2>
<p>In this article, we provide an intuitive, geometric interpretation of the covariance matrix, by exploring the relation between linear transformations and the resulting data covariance. Most textbooks explain the shape of data based on the concept of covariance matrices. Instead, we take a backwards approach and explain the concept of covariance matrices based on the shape of data.</p>
<div id="amzn-assoc-ad-b3cb92d7-7679-4d6e-9628-99f6459b00ca"></div>
<p><script async src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&#038;adInstanceId=b3cb92d7-7679-4d6e-9628-99f6459b00ca"></script><br />
In a previous article, we discussed the concept of <a title="Why divide the sample variance by N-1?" href="http://www.visiondummy.com/2014/03/divide-variance-n-1/" target="_blank">variance</a>, and provided a derivation and proof of the well known formula to estimate the sample variance. Figure 1 was used in this article to show that the standard deviation, as the square root of the variance, provides a measure of how much the data is spread across the feature space.</p>
<div id="attachment_213" style="width: 524px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/03/gaussiandensity.png"><img class="size-full wp-image-213 " style="margin: 0px;" title="Normal distribution" alt="Normal distribution" src="http://www.visiondummy.com/wp-content/uploads/2014/03/gaussiandensity.png" width="514" height="396" /></a><p class="wp-caption-text"><b>Figure 1.</b> Gaussian density function. For normally distributed data, 68% of the samples fall within the interval defined by the mean plus and minus the standard deviation.</p></div>
<p>We showed that an unbiased estimator of the sample variance can be obtained by:</p>
<p class="ql-center-displayed-equation" style="line-height: 129px;"><span class="ql-right-eqno"> (1) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-8511602375b6c3ba0dcf673f5fcdd8f9_l3.png" height="129" width="267" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#92;&#115;&#105;&#103;&#109;&#97;&#95;&#120;&#94;&#50;&#32;&#38;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#78;&#45;&#49;&#125;&#32;&#92;&#115;&#117;&#109;&#95;&#123;&#105;&#61;&#49;&#125;&#94;&#78;&#32;&#40;&#120;&#95;&#105;&#32;&#45;&#32;&#92;&#109;&#117;&#41;&#94;&#50;&#92;&#92; &#38;&#61;&#32;&#92;&#109;&#97;&#116;&#104;&#98;&#98;&#123;&#69;&#125;&#091;&#32;&#40;&#120;&#32;&#45;&#32;&#92;&#109;&#97;&#116;&#104;&#98;&#98;&#123;&#69;&#125;&#40;&#120;&#41;&#41;&#32;&#40;&#120;&#32;&#45;&#32;&#92;&#109;&#97;&#116;&#104;&#98;&#98;&#123;&#69;&#125;&#40;&#120;&#41;&#41;&#093;&#92;&#92; &#38;&#61;&#32;&#92;&#115;&#105;&#103;&#109;&#97;&#40;&#120;&#44;&#120;&#41; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>However, variance can only be used to explain the spread of the data in the directions parallel to the axes of the feature space. Consider the 2D feature space shown by figure 2:</p>
<div id="attachment_390" style="width: 391px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/04/transformeddata.png"><img class="size-full wp-image-390   " style="margin: 0px;" title="Data with a positive covariance" alt="Data with a positive covariance" src="http://www.visiondummy.com/wp-content/uploads/2014/04/transformeddata.png" width="381" height="369" /></a><p class="wp-caption-text"><b>Figure 2.</b> The diagnoal spread of the data is captured by the covariance.</p></div>
<p>For this data, we could calculate the variance <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-306b80c2caf6e1ce873db826824bae77_l3.png" class="ql-img-inline-formula " alt="&#92;&#115;&#105;&#103;&#109;&#97;&#40;&#120;&#44;&#120;&#41;" title="Rendered by QuickLaTeX.com" height="23" width="61" style="vertical-align: -6px;"/> in the x-direction and the variance <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-d0a6f8d59fd3d651e6d12aacb3804cb5_l3.png" class="ql-img-inline-formula " alt="&#92;&#115;&#105;&#103;&#109;&#97;&#40;&#121;&#44;&#121;&#41;" title="Rendered by QuickLaTeX.com" height="23" width="59" style="vertical-align: -6px;"/> in the y-direction. However, the horizontal spread and the vertical spread of the data does not explain the clear diagonal correlation. Figure 2 clearly shows that on average, if the x-value of a data point increases, then also the y-value increases, resulting in a positive correlation. This correlation can be captured by extending the notion of variance to what is called the &#8216;covariance&#8217; of the data:</p>
<p class="ql-center-displayed-equation" style="line-height: 23px;"><span class="ql-right-eqno"> (2) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-476cbf37a8d4f3765fe0b2b58e5c8706_l3.png" height="23" width="304" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#115;&#105;&#103;&#109;&#97;&#40;&#120;&#44;&#121;&#41;&#32;&#61;&#32;&#92;&#109;&#97;&#116;&#104;&#98;&#98;&#123;&#69;&#125;&#091;&#32;&#40;&#120;&#32;&#45;&#32;&#92;&#109;&#97;&#116;&#104;&#98;&#98;&#123;&#69;&#125;&#40;&#120;&#41;&#41;&#32;&#40;&#121;&#32;&#45;&#32;&#92;&#109;&#97;&#116;&#104;&#98;&#98;&#123;&#69;&#125;&#40;&#121;&#41;&#41;&#093; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>For 2D data, we thus obtain <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-306b80c2caf6e1ce873db826824bae77_l3.png" class="ql-img-inline-formula " alt="&#92;&#115;&#105;&#103;&#109;&#97;&#40;&#120;&#44;&#120;&#41;" title="Rendered by QuickLaTeX.com" height="23" width="61" style="vertical-align: -6px;"/>, <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-d0a6f8d59fd3d651e6d12aacb3804cb5_l3.png" class="ql-img-inline-formula " alt="&#92;&#115;&#105;&#103;&#109;&#97;&#40;&#121;&#44;&#121;&#41;" title="Rendered by QuickLaTeX.com" height="23" width="59" style="vertical-align: -6px;"/>, <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-88d33eb20eafcc741815d0fffe208e01_l3.png" class="ql-img-inline-formula " alt="&#92;&#115;&#105;&#103;&#109;&#97;&#40;&#120;&#44;&#121;&#41;" title="Rendered by QuickLaTeX.com" height="23" width="60" style="vertical-align: -6px;"/> and <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-42efe14d58befabbf2f821c96ced0b4a_l3.png" class="ql-img-inline-formula " alt="&#92;&#115;&#105;&#103;&#109;&#97;&#40;&#121;&#44;&#120;&#41;" title="Rendered by QuickLaTeX.com" height="23" width="60" style="vertical-align: -6px;"/>. These four values can be summarized in a matrix, called the covariance matrix:</p>
<p class="ql-center-displayed-equation" style="line-height: 64px;"><span class="ql-right-eqno"> (3) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-c3b2c0560068487dd51917cd55636781_l3.png" height="64" width="205" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#83;&#105;&#103;&#109;&#97;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#115;&#105;&#103;&#109;&#97;&#40;&#120;&#44;&#120;&#41;&#32;&#38;&#32;&#92;&#115;&#105;&#103;&#109;&#97;&#40;&#120;&#44;&#121;&#41;&#32;&#92;&#92;&#091;&#48;&#46;&#51;&#101;&#109;&#093; &#92;&#115;&#105;&#103;&#109;&#97;&#40;&#121;&#44;&#120;&#41;&#32;&#38;&#32;&#92;&#115;&#105;&#103;&#109;&#97;&#40;&#121;&#44;&#121;&#41;&#32;&#92;&#92;&#091;&#48;&#46;&#51;&#101;&#109;&#093; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>If x is positively correlated with y, y is also positively correlated with x. In other words, we can state that <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-a9f6d2d1f35bd9860e5975cd6a893877_l3.png" class="ql-img-inline-formula " alt="&#92;&#115;&#105;&#103;&#109;&#97;&#40;&#120;&#44;&#121;&#41;&#32;&#61;&#32;&#92;&#115;&#105;&#103;&#109;&#97;&#40;&#121;&#44;&#120;&#41;" title="Rendered by QuickLaTeX.com" height="23" width="150" style="vertical-align: -6px;"/>. Therefore, the covariance matrix is always a symmetric matrix with the variances on its diagonal and the covariances off-diagonal. Two-dimensional normally distributed data is explained completely by its mean and its <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-9550d59c0c85b85636acad265530a8ee_l3.png" class="ql-img-inline-formula " alt="&#50;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#50;" title="Rendered by QuickLaTeX.com" height="15" width="45" style="vertical-align: 0px;"/> covariance matrix. Similarly, a <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-9f4e76f38736d8026154c7113a886bc0_l3.png" class="ql-img-inline-formula " alt="&#51;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#51;" title="Rendered by QuickLaTeX.com" height="15" width="46" style="vertical-align: 0px;"/> covariance matrix is used to capture the spread of three-dimensional data, and a <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-27211e8b64d0af6bb1c7c805a18af057_l3.png" class="ql-img-inline-formula " alt="&#78;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#78;" title="Rendered by QuickLaTeX.com" height="14" width="64" style="vertical-align: 0px;"/> covariance matrix captures the spread of N-dimensional data.</p>
<p>Figure 3 illustrates how the overall shape of the data defines the covariance matrix:</p>
<div id="attachment_446" style="width: 503px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/04/covariances.png"><img class="size-full wp-image-446" style="margin: 0px;" title="The spread of the data is defined by its covariance matrix" alt="The spread of the data is defined by its covariance matrix" src="http://www.visiondummy.com/wp-content/uploads/2014/04/covariances.png" width="493" height="479" /></a><p class="wp-caption-text"><b>Figure 3.</b> The covariance matrix defines the shape of the data. Diagonal spread is captured by the covariance, while axis-aligned spread is captured by the variance.</p></div>
<h2>Eigendecomposition of a covariance matrix</h2>
<p>In the next section, we will discuss how the covariance matrix can be interpreted as a linear operator that transforms white data into the data we observed. However, before diving into the technical details, it is important to gain an intuitive understanding of how eigenvectors and eigenvalues uniquely define the covariance matrix, and therefore the shape of our data.</p>
<p>As we saw in figure 3, the covariance matrix defines both the spread (variance), and the orientation (covariance) of our data. So, if we would like to represent the covariance matrix with a vector and its magnitude, we should simply try to find the vector that points into the direction of the largest spread of the data, and whose magnitude equals the spread (variance) in this direction.</p>
<p>If we define this vector as <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-5663d3adf90e26dd70e1f371e6cd6eba_l3.png" class="ql-img-inline-formula " alt="&#92;&#118;&#101;&#99;&#123;&#118;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="13" style="vertical-align: 0px;"/>, then the projection of our data <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-6fe012cfdbc6f342dbd886ff568ed4ab_l3.png" class="ql-img-inline-formula " alt="&#68;" title="Rendered by QuickLaTeX.com" height="14" width="17" style="vertical-align: 0px;"/> onto this vector is obtained as <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-ccf1bdb39d78be778899729ac16806ba_l3.png" class="ql-img-inline-formula " alt="&#92;&#118;&#101;&#99;&#123;&#118;&#125;&#94;&#123;&#92;&#105;&#110;&#116;&#101;&#114;&#99;&#97;&#108;&#125;&#32;&#68;" title="Rendered by QuickLaTeX.com" height="15" width="37" style="vertical-align: 0px;"/>, and the variance of the projected data is <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-e76086e0b82464aff045e27892d04123_l3.png" class="ql-img-inline-formula " alt="&#92;&#118;&#101;&#99;&#123;&#118;&#125;&#94;&#123;&#92;&#105;&#110;&#116;&#101;&#114;&#99;&#97;&#108;&#125;&#32;&#92;&#83;&#105;&#103;&#109;&#97;&#32;&#92;&#118;&#101;&#99;&#123;&#118;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="49" style="vertical-align: 0px;"/>. Since we are looking for the vector <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-5663d3adf90e26dd70e1f371e6cd6eba_l3.png" class="ql-img-inline-formula " alt="&#92;&#118;&#101;&#99;&#123;&#118;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="13" style="vertical-align: 0px;"/> that points into the direction of the largest variance, we should choose its components such that the covariance matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-e76086e0b82464aff045e27892d04123_l3.png" class="ql-img-inline-formula " alt="&#92;&#118;&#101;&#99;&#123;&#118;&#125;&#94;&#123;&#92;&#105;&#110;&#116;&#101;&#114;&#99;&#97;&#108;&#125;&#32;&#92;&#83;&#105;&#103;&#109;&#97;&#32;&#92;&#118;&#101;&#99;&#123;&#118;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="49" style="vertical-align: 0px;"/> of the projected data is as large as possible. Maximizing any function of the form <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-e76086e0b82464aff045e27892d04123_l3.png" class="ql-img-inline-formula " alt="&#92;&#118;&#101;&#99;&#123;&#118;&#125;&#94;&#123;&#92;&#105;&#110;&#116;&#101;&#114;&#99;&#97;&#108;&#125;&#32;&#92;&#83;&#105;&#103;&#109;&#97;&#32;&#92;&#118;&#101;&#99;&#123;&#118;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="49" style="vertical-align: 0px;"/> with respect to <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-5663d3adf90e26dd70e1f371e6cd6eba_l3.png" class="ql-img-inline-formula " alt="&#92;&#118;&#101;&#99;&#123;&#118;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="13" style="vertical-align: 0px;"/>, where <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-5663d3adf90e26dd70e1f371e6cd6eba_l3.png" class="ql-img-inline-formula " alt="&#92;&#118;&#101;&#99;&#123;&#118;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="13" style="vertical-align: 0px;"/> is a normalized unit vector, can be formulated as a so called <a href="http://en.wikipedia.org/wiki/Rayleigh_quotient" title="Rayleigh Quotient" target="_blank">Rayleigh Quotient</a>. The maximum of such a Rayleigh Quotient is obtained by setting <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-5663d3adf90e26dd70e1f371e6cd6eba_l3.png" class="ql-img-inline-formula " alt="&#92;&#118;&#101;&#99;&#123;&#118;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="13" style="vertical-align: 0px;"/> equal to the largest eigenvector of matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-66f091b3d894ca4b0418d9487b6b7e8a_l3.png" class="ql-img-inline-formula " alt="&#92;&#83;&#105;&#103;&#109;&#97;" title="Rendered by QuickLaTeX.com" height="15" width="13" style="vertical-align: 0px;"/>.</p>
<p>In other words, the largest eigenvector of the covariance matrix always points into the direction of the largest variance of the data, and the magnitude of this vector equals the corresponding eigenvalue. The second largest eigenvector is always orthogonal to the largest eigenvector, and points into the direction of the second largest spread of the data.</p>
<p>Now let&#8217;s have a look at some examples. In an earlier article we saw that a linear transformation matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-99bdf2edc1f86c3fa1d60f4d82513c7d_l3.png" class="ql-img-inline-formula " alt="&#84;" title="Rendered by QuickLaTeX.com" height="14" width="15" style="vertical-align: 0px;"/> is completely defined by its <a title="What are eigenvectors and eigenvalues?" href="http://www.visiondummy.com/2014/03/eigenvalues-eigenvectors/" target="_blank">eigenvectors and eigenvalues</a>. Applied to the covariance matrix, this means that:<br />
<a name="id3483335494"></a>
<p class="ql-center-displayed-equation" style="line-height: 15px;"><span class="ql-right-eqno"> (4) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-a17919125852783f2014314d7368316e_l3.png" height="15" width="79" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;&#32; &#92;&#83;&#105;&#103;&#109;&#97;&#32;&#92;&#118;&#101;&#99;&#123;&#118;&#125;&#32;&#61;&#32;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#32;&#92;&#118;&#101;&#99;&#123;&#118;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>where <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-5663d3adf90e26dd70e1f371e6cd6eba_l3.png" class="ql-img-inline-formula " alt="&#92;&#118;&#101;&#99;&#123;&#118;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="13" style="vertical-align: 0px;"/> is an eigenvector of <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-66f091b3d894ca4b0418d9487b6b7e8a_l3.png" class="ql-img-inline-formula " alt="&#92;&#83;&#105;&#103;&#109;&#97;" title="Rendered by QuickLaTeX.com" height="15" width="13" style="vertical-align: 0px;"/>, and <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-50bc2c4701f0a0dd472fdd7dad5c47d9_l3.png" class="ql-img-inline-formula " alt="&#92;&#108;&#97;&#109;&#98;&#100;&#97;" title="Rendered by QuickLaTeX.com" height="14" width="11" style="vertical-align: 0px;"/> is the corresponding eigenvalue.</p>
<p>If the covariance matrix of our data is a diagonal matrix, such that the covariances are zero, then this means that the variances must be equal to the eigenvalues <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-50bc2c4701f0a0dd472fdd7dad5c47d9_l3.png" class="ql-img-inline-formula " alt="&#92;&#108;&#97;&#109;&#98;&#100;&#97;" title="Rendered by QuickLaTeX.com" height="14" width="11" style="vertical-align: 0px;"/>. This is illustrated by figure 4, where the eigenvectors are shown in green and magenta, and where the eigenvalues clearly equal the variance components of the covariance matrix.</p>
<div id="attachment_603" style="width: 810px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/04/eigenvectors.png"><img src="http://www.visiondummy.com/wp-content/uploads/2014/04/eigenvectors.png" alt="Eigenvectors of a covariance matrix" width="800" height="383" class="size-full wp-image-603" /></a><p class="wp-caption-text"><b>Figure 4.</b> Eigenvectors of a covariance matrix</p></div>
<p>However, if the covariance matrix is not diagonal, such that the covariances are not zero, then the situation is a little more complicated. The eigenvalues still represent the variance magnitude in the direction of the largest spread of the data, and the variance components of the covariance matrix still represent the variance magnitude in the direction of the x-axis and y-axis. But since the data is not axis aligned, these values are not the same anymore as shown by figure 5.</p>
<div id="attachment_604" style="width: 810px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/04/eigenvectors_covariance.png"><img src="http://www.visiondummy.com/wp-content/uploads/2014/04/eigenvectors_covariance.png" alt="Eigenvectors with covariance" width="800" height="382" class="size-full wp-image-604" /></a><p class="wp-caption-text"><b>Figure 5.</b> Eigenvalues versus variance</p></div>
<p>By comparing figure 5 with figure 4, it becomes clear that the eigenvalues represent the variance of the data along the eigenvector directions, whereas the variance components of the covariance matrix represent the spread along the axes. If there are no covariances, then both values are equal.</p>
<h2>Covariance matrix as a linear transformation</h2>
<p>Now let&#8217;s forget about covariance matrices for a moment. Each of the examples in figure 3 can simply be considered to be a linearly transformed instance of figure 6:</p>
<div id="attachment_447" style="width: 391px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/04/whiteneddata.png"><img class="size-full wp-image-447" style="margin: 0px;" title="White data" alt="White data" src="http://www.visiondummy.com/wp-content/uploads/2014/04/whiteneddata.png" width="381" height="369" /></a><p class="wp-caption-text"><b>Figure 6.</b> Data with unit covariance matrix is called white data.</p></div>
<p>Let the data shown by figure 6 be <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-6fe012cfdbc6f342dbd886ff568ed4ab_l3.png" class="ql-img-inline-formula " alt="&#68;" title="Rendered by QuickLaTeX.com" height="14" width="17" style="vertical-align: 0px;"/>, then each of the examples shown by figure 3 can be obtained by linearly transforming <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-6fe012cfdbc6f342dbd886ff568ed4ab_l3.png" class="ql-img-inline-formula " alt="&#68;" title="Rendered by QuickLaTeX.com" height="14" width="17" style="vertical-align: 0px;"/>:</p>
<p class="ql-center-displayed-equation" style="line-height: 18px;"><span class="ql-right-eqno"> (5) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-7aecb171a514b3c704f078ec86182805_l3.png" height="18" width="87" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#68;&#39;&#32;&#61;&#32;&#84;&#32;&#92;&#44;&#32;&#68; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>where <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-99bdf2edc1f86c3fa1d60f4d82513c7d_l3.png" class="ql-img-inline-formula " alt="&#84;" title="Rendered by QuickLaTeX.com" height="14" width="15" style="vertical-align: 0px;"/> is a transformation matrix consisting of a rotation matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-026035461a80f8e10b18e494d1116782_l3.png" class="ql-img-inline-formula " alt="&#82;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/> and a scaling matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-7f83dd23b1b356198dd90895630ebcef_l3.png" class="ql-img-inline-formula " alt="&#83;" title="Rendered by QuickLaTeX.com" height="14" width="13" style="vertical-align: 0px;"/>:<br />
<a name="id1585768567"></a>
<p class="ql-center-displayed-equation" style="line-height: 14px;"><span class="ql-right-eqno"> (6) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-2481ecd212935a8cc503131bf2596bf6_l3.png" height="14" width="81" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#84;&#32;&#61;&#32;&#82;&#32;&#92;&#44;&#32;&#83;&#46; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>These matrices are defined as:</p>
<p class="ql-center-displayed-equation" style="line-height: 64px;"><span class="ql-right-eqno"> (7) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-78bf053271a867c2d5b7c2b30d3e7924_l3.png" height="64" width="211" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#82;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#99;&#111;&#115;&#40;&#92;&#116;&#104;&#101;&#116;&#97;&#41;&#32;&#38;&#32;&#45;&#92;&#115;&#105;&#110;&#40;&#92;&#116;&#104;&#101;&#116;&#97;&#41;&#32;&#92;&#92;&#091;&#48;&#46;&#51;&#101;&#109;&#093; &#92;&#115;&#105;&#110;&#40;&#92;&#116;&#104;&#101;&#116;&#97;&#41;&#32;&#38;&#32;&#92;&#99;&#111;&#115;&#40;&#92;&#116;&#104;&#101;&#116;&#97;&#41; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>where <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-a633c6dcc2aba17ef85b129e4fbcaf98_l3.png" class="ql-img-inline-formula " alt="&#92;&#116;&#104;&#101;&#116;&#97;" title="Rendered by QuickLaTeX.com" height="14" width="10" style="vertical-align: 0px;"/> is the rotation angle, and:</p>
<p class="ql-center-displayed-equation" style="line-height: 64px;"><span class="ql-right-eqno"> (8) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-0756bebe1440213107fea1005e1a655b_l3.png" height="64" width="120" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#83;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#115;&#95;&#120;&#32;&#38;&#32;&#48;&#32;&#92;&#92;&#091;&#48;&#46;&#51;&#101;&#109;&#093; &#48;&#32;&#38;&#32;&#115;&#95;&#121; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>where <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-197e94159cb0b049505c16b6448e224c_l3.png" class="ql-img-inline-formula " alt="&#115;&#95;&#120;" title="Rendered by QuickLaTeX.com" height="12" width="18" style="vertical-align: -3px;"/> and <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-1be2a4d3326735aa17afcfc4d6409278_l3.png" class="ql-img-inline-formula " alt="&#115;&#95;&#121;" title="Rendered by QuickLaTeX.com" height="15" width="18" style="vertical-align: -6px;"/> are the scaling factors in the x direction and the y direction respectively.</p>
<p>In the following paragraphs, we will discuss the relation between the covariance matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-66f091b3d894ca4b0418d9487b6b7e8a_l3.png" class="ql-img-inline-formula " alt="&#92;&#83;&#105;&#103;&#109;&#97;" title="Rendered by QuickLaTeX.com" height="15" width="13" style="vertical-align: 0px;"/>, and the linear transformation matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-b40eb258e9e321e3d2262a5afffcc8bb_l3.png" class="ql-img-inline-formula " alt="&#84;&#32;&#61;&#32;&#82;&#92;&#44;&#32;&#83;" title="Rendered by QuickLaTeX.com" height="14" width="77" style="vertical-align: 0px;"/>.</p>
<p>Let&#8217;s start with unscaled (scale equals 1) and unrotated data. In statistics this is often refered to as &#8216;white data&#8217; because its samples are drawn from a standard normal distribution and therefore correspond to white (uncorrelated) noise:</p>
<div id="attachment_394" style="width: 391px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/04/whiteneddata.png"><img class="size-full wp-image-394 " style="margin: 0px;" title="Whitened data" alt="Whitened data" src="http://www.visiondummy.com/wp-content/uploads/2014/04/whiteneddata.png" width="381" height="369" /></a><p class="wp-caption-text"><b>Figure 7.</b> White data is data with a unit covariance matrix.</p></div>
<p>The covariance matrix of this &#8216;white&#8217; data equals the identity matrix, such that the variances and standard deviations equal 1 and the covariance equals zero:</p>
<p class="ql-center-displayed-equation" style="line-height: 64px;"><span class="ql-right-eqno"> (9) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-22cfcbfd49a80711b48bee89d0ac5e9e_l3.png" height="64" width="218" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#83;&#105;&#103;&#109;&#97;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#115;&#105;&#103;&#109;&#97;&#95;&#120;&#94;&#50;&#32;&#38;&#32;&#48;&#32;&#92;&#92;&#091;&#48;&#46;&#51;&#101;&#109;&#093; &#48;&#32;&#38;&#32;&#92;&#115;&#105;&#103;&#109;&#97;&#95;&#121;&#94;&#50;&#32;&#92;&#92; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#49;&#32;&#38;&#32;&#48;&#32;&#92;&#92;&#091;&#48;&#46;&#51;&#101;&#109;&#093; &#48;&#32;&#38;&#32;&#49;&#32;&#92;&#92; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Now let&#8217;s scale the data in the x-direction with a factor 4:</p>
<p class="ql-center-displayed-equation" style="line-height: 64px;"><span class="ql-right-eqno"> (10) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-93925ded582a8e859f4efd17c75d7dc9_l3.png" height="64" width="141" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#68;&#39;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#52;&#32;&#38;&#32;&#48;&#32;&#92;&#92;&#091;&#48;&#46;&#51;&#101;&#109;&#093; &#48;&#32;&#38;&#32;&#49;&#32;&#92;&#92; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#92;&#44;&#32;&#68; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>The data <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-69e87a5558d2fcd98b5a9d1292a4345e_l3.png" class="ql-img-inline-formula " alt="&#68;&#39;" title="Rendered by QuickLaTeX.com" height="17" width="23" style="vertical-align: 0px;"/> now looks as follows:</p>
<div id="attachment_400" style="width: 391px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/04/stretcheddata.png"><img class="size-full wp-image-400" style="margin: 0px;" title="Data with variance in the x-direction" alt="Data with variance in the x-direction" src="http://www.visiondummy.com/wp-content/uploads/2014/04/stretcheddata.png" width="381" height="369" /></a><p class="wp-caption-text"><b>Figure 8.</b> Variance in the x-direction results in a horizontal scaling.</p></div>
<p>The covariance matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-6a91d339ba236a991b48b26135dd4246_l3.png" class="ql-img-inline-formula " alt="&#92;&#83;&#105;&#103;&#109;&#97;&#39;" title="Rendered by QuickLaTeX.com" height="17" width="19" style="vertical-align: 0px;"/> of <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-69e87a5558d2fcd98b5a9d1292a4345e_l3.png" class="ql-img-inline-formula " alt="&#68;&#39;" title="Rendered by QuickLaTeX.com" height="17" width="23" style="vertical-align: 0px;"/> is now:</p>
<p class="ql-center-displayed-equation" style="line-height: 64px;"><span class="ql-right-eqno"> (11) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-b17970f14e6400c5fc20c4b9c069abfd_l3.png" height="64" width="234" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#83;&#105;&#103;&#109;&#97;&#39;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#115;&#105;&#103;&#109;&#97;&#95;&#120;&#94;&#50;&#32;&#38;&#32;&#48;&#32;&#92;&#92;&#091;&#48;&#46;&#51;&#101;&#109;&#093; &#48;&#32;&#38;&#32;&#92;&#115;&#105;&#103;&#109;&#97;&#95;&#121;&#94;&#50;&#32;&#92;&#92; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#49;&#54;&#32;&#38;&#32;&#48;&#32;&#92;&#92;&#091;&#48;&#46;&#51;&#101;&#109;&#093; &#48;&#32;&#38;&#32;&#49;&#32;&#92;&#92; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Thus, the covariance matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-6a91d339ba236a991b48b26135dd4246_l3.png" class="ql-img-inline-formula " alt="&#92;&#83;&#105;&#103;&#109;&#97;&#39;" title="Rendered by QuickLaTeX.com" height="17" width="19" style="vertical-align: 0px;"/> of the resulting data <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-69e87a5558d2fcd98b5a9d1292a4345e_l3.png" class="ql-img-inline-formula " alt="&#68;&#39;" title="Rendered by QuickLaTeX.com" height="17" width="23" style="vertical-align: 0px;"/> is related to the linear transformation <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-99bdf2edc1f86c3fa1d60f4d82513c7d_l3.png" class="ql-img-inline-formula " alt="&#84;" title="Rendered by QuickLaTeX.com" height="14" width="15" style="vertical-align: 0px;"/> that is applied to the original data as follows: <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-9bd559b313e798679ab85e7718dea765_l3.png" class="ql-img-inline-formula " alt="&#68;&#39;&#32;&#61;&#32;&#84;&#32;&#92;&#44;&#32;&#68;" title="Rendered by QuickLaTeX.com" height="17" width="87" style="vertical-align: 0px;"/>, where<br />
<a name="id537686066"></a>
<p class="ql-center-displayed-equation" style="line-height: 64px;"><span class="ql-right-eqno"> (12) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-51df1544156ec5782e7799b4782b029b_l3.png" height="64" width="183" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#84;&#32;&#61;&#32;&#92;&#115;&#113;&#114;&#116;&#123;&#92;&#83;&#105;&#103;&#109;&#97;&#39;&#125;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#52;&#32;&#38;&#32;&#48;&#32;&#92;&#92;&#091;&#48;&#46;&#51;&#101;&#109;&#093; &#48;&#32;&#38;&#32;&#49;&#32;&#92;&#92; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#46; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>However, although equation (<a href="#id537686066">12</a>) holds when the data is scaled in the x and y direction, the question rises if it also holds when a rotation is applied. To investigate the relation between the linear transformation matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-99bdf2edc1f86c3fa1d60f4d82513c7d_l3.png" class="ql-img-inline-formula " alt="&#84;" title="Rendered by QuickLaTeX.com" height="14" width="15" style="vertical-align: 0px;"/> and the covariance matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-6a91d339ba236a991b48b26135dd4246_l3.png" class="ql-img-inline-formula " alt="&#92;&#83;&#105;&#103;&#109;&#97;&#39;" title="Rendered by QuickLaTeX.com" height="17" width="19" style="vertical-align: 0px;"/> in the general case, we will therefore try to decompose the covariance matrix into the product of rotation and scaling matrices.</p>
<p>As we saw earlier, we can represent the covariance matrix by its eigenvectors and eigenvalues:<br />
<a name="id3483335494"></a>
<p class="ql-center-displayed-equation" style="line-height: 15px;"><span class="ql-right-eqno"> (13) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-a17919125852783f2014314d7368316e_l3.png" height="15" width="79" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;&#32; &#92;&#83;&#105;&#103;&#109;&#97;&#32;&#92;&#118;&#101;&#99;&#123;&#118;&#125;&#32;&#61;&#32;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#32;&#92;&#118;&#101;&#99;&#123;&#118;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>where <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-5663d3adf90e26dd70e1f371e6cd6eba_l3.png" class="ql-img-inline-formula " alt="&#92;&#118;&#101;&#99;&#123;&#118;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="13" style="vertical-align: 0px;"/> is an eigenvector of <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-66f091b3d894ca4b0418d9487b6b7e8a_l3.png" class="ql-img-inline-formula " alt="&#92;&#83;&#105;&#103;&#109;&#97;" title="Rendered by QuickLaTeX.com" height="15" width="13" style="vertical-align: 0px;"/>, and <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-50bc2c4701f0a0dd472fdd7dad5c47d9_l3.png" class="ql-img-inline-formula " alt="&#92;&#108;&#97;&#109;&#98;&#100;&#97;" title="Rendered by QuickLaTeX.com" height="14" width="11" style="vertical-align: 0px;"/> is the corresponding eigenvalue.</p>
<p>Equation (<a href="#id3483335494">13</a>) holds for each eigenvector-eigenvalue pair of matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-66f091b3d894ca4b0418d9487b6b7e8a_l3.png" class="ql-img-inline-formula " alt="&#92;&#83;&#105;&#103;&#109;&#97;" title="Rendered by QuickLaTeX.com" height="15" width="13" style="vertical-align: 0px;"/>. In the 2D case, we obtain two eigenvectors and two eigenvalues. The system of two equations defined by equation (<a href="#id3483335494">13</a>) can be represented efficiently using matrix notation:<br />
<a name="id1495159919"></a>
<p class="ql-center-displayed-equation" style="line-height: 15px;"><span class="ql-right-eqno"> (14) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-f6fdbf4f1af6863c9afc04f7418fdc6f_l3.png" height="15" width="97" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;&#32; &#92;&#83;&#105;&#103;&#109;&#97;&#32;&#92;&#44;&#32;&#86;&#32;&#61;&#32;&#86;&#32;&#92;&#44;&#32;&#76; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>where <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-1f1ceff6690e6ea05bc7802220277816_l3.png" class="ql-img-inline-formula " alt="&#86;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/> is the matrix whose columns are the eigenvectors of <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-66f091b3d894ca4b0418d9487b6b7e8a_l3.png" class="ql-img-inline-formula " alt="&#92;&#83;&#105;&#103;&#109;&#97;" title="Rendered by QuickLaTeX.com" height="15" width="13" style="vertical-align: 0px;"/> and <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-f8016ff830b491e0b1f3122a41ccff3f_l3.png" class="ql-img-inline-formula " alt="&#76;" title="Rendered by QuickLaTeX.com" height="14" width="14" style="vertical-align: 0px;"/> is the diagonal matrix whose non-zero elements are the corresponding eigenvalues.</p>
<p>This means that we can represent the covariance matrix as a function of its eigenvectors and eigenvalues:<br />
<a name="id2430180844"></a>
<p class="ql-center-displayed-equation" style="line-height: 20px;"><span class="ql-right-eqno"> (15) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-1bd7a6edabf351786ae510e2c02d1663_l3.png" height="20" width="117" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;&#32; &#92;&#83;&#105;&#103;&#109;&#97;&#32;&#61;&#32;&#86;&#32;&#92;&#44;&#32;&#76;&#32;&#92;&#44;&#32;&#86;&#94;&#123;&#45;&#49;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Equation (<a href="#id2430180844">15</a>) is called the eigendecomposition of the covariance matrix and can be obtained using a <a title="Singular Value Decomposition" href="https://en.wikipedia.org/wiki/Singular_value_decomposition" target="_blank">Singular Value Decomposition</a> algorithm. Whereas the eigenvectors represent the directions of the largest variance of the data, the eigenvalues represent the magnitude of this variance in those directions. In other words, <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-1f1ceff6690e6ea05bc7802220277816_l3.png" class="ql-img-inline-formula " alt="&#86;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/> represents a rotation matrix, while <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-8235da3a0beb2b3fd48aef3af7ba37fa_l3.png" class="ql-img-inline-formula " alt="&#92;&#115;&#113;&#114;&#116;&#123;&#76;&#125;" title="Rendered by QuickLaTeX.com" height="22" width="32" style="vertical-align: -3px;"/> represents a scaling matrix. The covariance matrix can thus be decomposed further as:<br />
<a name="id2743526996"></a>
<p class="ql-center-displayed-equation" style="line-height: 20px;"><span class="ql-right-eqno"> (16) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-23df767e6fb3e95725feacf9467b019e_l3.png" height="20" width="133" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;&#32; &#92;&#83;&#105;&#103;&#109;&#97;&#32;&#61;&#32;&#82;&#32;&#92;&#44;&#32;&#83;&#32;&#92;&#44;&#32;&#83;&#32;&#92;&#44;&#32;&#82;&#94;&#123;&#45;&#49;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>where <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-7c0435dd691dcbce6e1b3121ba27bbd6_l3.png" class="ql-img-inline-formula " alt="&#82;&#61;&#86;" title="Rendered by QuickLaTeX.com" height="14" width="61" style="vertical-align: 0px;"/> is a rotation matrix and <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-3262ef230355c0fef4406d0637062a28_l3.png" class="ql-img-inline-formula " alt="&#83;&#61;&#92;&#115;&#113;&#114;&#116;&#123;&#76;&#125;" title="Rendered by QuickLaTeX.com" height="22" width="74" style="vertical-align: -3px;"/> is a scaling matrix.</p>
<p>In equation (<a href="#id1585768567">6</a>) we defined a linear transformation <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-35bf2c5b24b044c78d4ac3ecff5b2078_l3.png" class="ql-img-inline-formula " alt="&#84;&#61;&#82;&#32;&#92;&#44;&#32;&#83;" title="Rendered by QuickLaTeX.com" height="14" width="77" style="vertical-align: 0px;"/>. Since <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-7f83dd23b1b356198dd90895630ebcef_l3.png" class="ql-img-inline-formula " alt="&#83;" title="Rendered by QuickLaTeX.com" height="14" width="13" style="vertical-align: 0px;"/> is a diagonal scaling matrix, <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-e6305c54d65d420123b47b07e403a536_l3.png" class="ql-img-inline-formula " alt="&#83;&#32;&#61;&#32;&#83;&#94;&#123;&#92;&#105;&#110;&#116;&#101;&#114;&#99;&#97;&#108;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="63" style="vertical-align: 0px;"/>. Furthermore, since <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-026035461a80f8e10b18e494d1116782_l3.png" class="ql-img-inline-formula " alt="&#82;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/> is an orthogonal matrix, <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-945fcf37014dbf658e49128ad721040e_l3.png" class="ql-img-inline-formula " alt="&#82;&#94;&#123;&#45;&#49;&#125;&#32;&#61;&#32;&#82;&#94;&#123;&#92;&#105;&#110;&#116;&#101;&#114;&#99;&#97;&#108;&#125;" title="Rendered by QuickLaTeX.com" height="19" width="90" style="vertical-align: 0px;"/>. Therefore, <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-205b466d7f5da5d6cff27d6859693391_l3.png" class="ql-img-inline-formula " alt="&#84;&#94;&#123;&#92;&#105;&#110;&#116;&#101;&#114;&#99;&#97;&#108;&#125;&#32;&#61;&#32;&#40;&#82;&#32;&#92;&#44;&#32;&#83;&#41;&#94;&#123;&#92;&#105;&#110;&#116;&#101;&#114;&#99;&#97;&#108;&#125;&#32;&#61;&#32;&#83;&#94;&#123;&#92;&#105;&#110;&#116;&#101;&#114;&#99;&#97;&#108;&#125;&#32;&#92;&#44;&#32;&#82;&#94;&#123;&#92;&#105;&#110;&#116;&#101;&#114;&#99;&#97;&#108;&#125;&#32;&#61;&#32;&#83;&#32;&#92;&#44;&#32;&#82;&#94;&#123;&#45;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="25" width="275" style="vertical-align: -6px;"/>. The covariance matrix can thus be written as:<br />
<a name="id3282722977"></a>
<p class="ql-center-displayed-equation" style="line-height: 24px;"><span class="ql-right-eqno"> (17) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-5889c4c6b55d1c90107dd9fc09195d1c_l3.png" height="24" width="212" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;&#32; &#92;&#83;&#105;&#103;&#109;&#97;&#32;&#61;&#32;&#82;&#32;&#92;&#44;&#32;&#83;&#32;&#92;&#44;&#32;&#83;&#32;&#92;&#44;&#32;&#82;&#94;&#123;&#45;&#49;&#125;&#32;&#61;&#32;&#84;&#32;&#92;&#44;&#32;&#84;&#94;&#123;&#92;&#105;&#110;&#116;&#101;&#114;&#99;&#97;&#108;&#125;&#44; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>In other words, if we apply the linear transformation defined by <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-35bf2c5b24b044c78d4ac3ecff5b2078_l3.png" class="ql-img-inline-formula " alt="&#84;&#61;&#82;&#32;&#92;&#44;&#32;&#83;" title="Rendered by QuickLaTeX.com" height="14" width="77" style="vertical-align: 0px;"/> to the original white data <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-6fe012cfdbc6f342dbd886ff568ed4ab_l3.png" class="ql-img-inline-formula " alt="&#68;" title="Rendered by QuickLaTeX.com" height="14" width="17" style="vertical-align: 0px;"/> shown by figure 7, we obtain the rotated and scaled data <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-69e87a5558d2fcd98b5a9d1292a4345e_l3.png" class="ql-img-inline-formula " alt="&#68;&#39;" title="Rendered by QuickLaTeX.com" height="17" width="23" style="vertical-align: 0px;"/> with covariance matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-c518de6c373241128e4f4bbb640476a1_l3.png" class="ql-img-inline-formula " alt="&#84;&#32;&#92;&#44;&#32;&#84;&#94;&#123;&#92;&#105;&#110;&#116;&#101;&#114;&#99;&#97;&#108;&#125;&#32;&#61;&#32;&#92;&#83;&#105;&#103;&#109;&#97;&#39;&#32;&#61;&#32;&#82;&#32;&#92;&#44;&#32;&#83;&#32;&#92;&#44;&#32;&#83;&#32;&#92;&#44;&#32;&#82;&#94;&#123;&#45;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="19" width="211" style="vertical-align: 0px;"/>. This is illustrated by figure 10:</p>
<div id="attachment_407" style="width: 950px" class="wp-caption aligncenter"><a href="http://www.visiondummy.com/wp-content/uploads/2014/04/lineartrans.png"><img class="size-full wp-image-407 " style="margin: 0px;" title="The covariance matrix represents a linear transformation of the original data" alt="The covariance matrix represents a linear transformation of the original data" src="http://www.visiondummy.com/wp-content/uploads/2014/04/lineartrans.png" width="940" height="451" /></a><p class="wp-caption-text"><b>Figure 10.</b> The covariance matrix represents a linear transformation of the original data.</p></div>
<p>The colored arrows in figure 10 represent the eigenvectors. The largest eigenvector, i.e. the eigenvector with the largest corresponding eigenvalue, always points in the direction of the largest variance of the data and thereby defines its orientation. Subsequent eigenvectors are always orthogonal to the largest eigenvector due to the orthogonality of rotation matrices.</p>
<h2>Conclusion</h2>
<p>In this article we showed that the covariance matrix of observed data is directly related to a linear transformation of white, uncorrelated data. This linear transformation is completely defined by the eigenvectors and eigenvalues of the data. While the eigenvectors represent the rotation matrix, the eigenvalues correspond to the square of the scaling factor in each dimension.</p>
<p><strong>If you&#8217;re new to this blog, don&#8217;t forget to subscribe, or <a href="https://twitter.com/vincent_spruyt" title="Follow me on Twitter!" target="_blank">follow me on twitter</a>!</strong><br />


<!-- Form created by Optin Forms plugin by Codeleon: create beautiful optin forms with ease! -->
<!-- http://codeleon.com/products/optin-forms/ -->
<div id="optinforms-form5-container" ><form method="post" target="_blank" action="http://visiondummy.us10.list-manage.com/subscribe/post?u=c435905e10ead915f3917d694&id=bbdfb33a9f"><div id="optinforms-form5" style="background:#ffffff;"><div id="optinforms-form5-container-left"><div id="optinforms-form5-title" style="font-family:News Cycle; font-size:24px; line-height:24px; color:#fd4326">JOIN MY NEWSLETTER</div><!--optinforms-form5-title--><input type="text" id="optinforms-form5-name-field" name="FNAME" placeholder="Enter Your Name" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#000000" /><input type="text" id="optinforms-form5-email-field" name="EMAIL" placeholder="Enter Your Email" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#000000" /><input type="submit" name="submit" id="optinforms-form5-button" value="SUBSCRIBE" style="font-family:Arial, Helvetica, sans-serif; font-size:16px; color:#FFFFFF; background-color:#fd4326" /></div><!--optinforms-form5-container-left--><div id="optinforms-form5-container-right"><div id="optinforms-form5-subtitle" style="font-family:Georgia; font-size:16px; color:#444444">Receive my newsletter to get notified when new articles and code snippets become available on my blog!</div><!--optinforms-form5-subtitle--><div id="optinforms-form5-disclaimer" style="font-family:Georgia, Times New Roman, Times, serif; font-size:14px; color:#727272">We all hate spam. Your email address will not be sold or shared with anyone else.</div><!--optinforms-form5-disclaimer--></div><!--optinforms-form5-container-right--><div class="clear"></div></div><!--optinforms-form5--><div class="clear"></div></form></div><!--optinforms-form5-container--><div class="clear"></div>
<!-- / Optin Forms -->

<style type='text/css'></style></p>
<p>The post <a rel="nofollow" href="https://www.visiondummy.com/2014/04/geometric-interpretation-covariance-matrix/">A geometric interpretation of the covariance matrix</a> appeared first on <a rel="nofollow" href="https://www.visiondummy.com">Computer vision for dummies</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.visiondummy.com/2014/04/geometric-interpretation-covariance-matrix/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
		<item>
		<title>What are eigenvectors and eigenvalues?</title>
		<link>https://www.visiondummy.com/2014/03/eigenvalues-eigenvectors/</link>
		<comments>https://www.visiondummy.com/2014/03/eigenvalues-eigenvectors/#comments</comments>
		<pubDate>Wed, 05 Mar 2014 14:44:53 +0000</pubDate>
		<dc:creator><![CDATA[Vincent Spruyt]]></dc:creator>
				<category><![CDATA[Linear algebra]]></category>
		<category><![CDATA[Eigenfaces]]></category>
		<category><![CDATA[Eigenvalues]]></category>
		<category><![CDATA[Eigenvectors]]></category>
		<category><![CDATA[PCA]]></category>

		<guid isPermaLink="false">http://www.visiondummy.com/?p=111</guid>
		<description><![CDATA[<p>Eigenvectors and eigenvalues have many important applications in computer vision and machine learning in general. Well known examples are PCA (Principal Component Analysis) for dimensionality reduction or EigenFaces for face recognition. An interesting use of eigenvectors and eigenvalues is also illustrated in my post about error ellipses. Furthermore, eigendecomposition forms the base of the geometric [...]</p>
<p>The post <a rel="nofollow" href="https://www.visiondummy.com/2014/03/eigenvalues-eigenvectors/">What are eigenvectors and eigenvalues?</a> appeared first on <a rel="nofollow" href="https://www.visiondummy.com">Computer vision for dummies</a>.</p>
]]></description>
				<content:encoded><![CDATA[<h2>Introduction</h2>
<p>Eigenvectors and eigenvalues have many important applications in computer vision and machine learning in general. Well known examples are <a href="http://www.visiondummy.com/2014/05/feature-extraction-using-pca/" title="Feature extraction using PCA" target="_blank">PCA (Principal Component Analysis)</a> for dimensionality reduction or <a href="http://www.visiondummy.com/2014/05/feature-extraction-using-pca/#A_practical_PCA_application_Eigenfaces" title="Eigenfaces" target="_blank">EigenFaces</a> for face recognition. An interesting use of eigenvectors and eigenvalues is also illustrated in my post about <a href="http://www.visiondummy.com/2014/04/draw-error-ellipse-representing-covariance-matrix/" title="How to draw a covariance error ellipse?" target="_blank">error ellipses</a>. Furthermore, eigendecomposition forms the base of the geometric interpretation of covariance matrices, discussed in an <a href="http://www.visiondummy.com/2014/04/geometric-interpretation-covariance-matrix/" title="A geometric interpretation of the covariance matrix" target="_blank">more recent post</a>. In this article, I will provide a gentle introduction into this mathematical concept, and will show how to manually obtain the eigendecomposition of a 2D square matrix.</p>
<p>An eigenvector is a vector whose direction remains unchanged when a linear transformation is applied to it. Consider the image below in which three vectors are shown. The green square is only drawn to illustrate the linear transformation that is applied to each of these three vectors.</p>
<div id="attachment_128" style="width: 525px" class="wp-caption aligncenter"><a title="Eigenvectors image" href="http://www.visiondummy.com/wp-content/uploads/2014/03/eigenvectors.png" target="_blank"><img class="size-full wp-image-128   " style="border: 0px; margin-top: 0px; margin-bottom: 0px;" title="eigenvectors" alt="eigenvectors" src="http://www.visiondummy.com/wp-content/uploads/2014/03/eigenvectors.png" width="515" height="217" /></a><p class="wp-caption-text">Eigenvectors (red) do not change direction when a linear transformation (e.g. scaling) is applied to them. Other vectors (yellow) do.</p></div>
<p>The transformation in this case is a simple scaling with factor 2 in the horizontal direction and factor 0.5 in the vertical direction, such that the transformation matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-3fae06210cb4529155c990d8d9838d68_l3.png" class="ql-img-inline-formula " alt="&#65;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/> is defined as:</p>
<p align="center"><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-7c07ea3c8536c266a96b8d3c430fda32_l3.png" class="ql-img-inline-formula " alt="&#65;&#61;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#50;&#32;&#38;&#32;&#48;&#32;&#92;&#92;&#32;&#48;&#32;&#38;&#32;&#48;&#46;&#53;&#32;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;" title="Rendered by QuickLaTeX.com" height="51" width="118" style="vertical-align: -20px;"/>.</p>
<p>A vector <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-0fd80e210150f4e468bd01b12d868319_l3.png" class="ql-img-inline-formula " alt="&#92;&#118;&#101;&#99;&#123;&#118;&#125;&#61;&#40;&#120;&#44;&#121;&#41;" title="Rendered by QuickLaTeX.com" height="23" width="87" style="vertical-align: -6px;"/> is then scaled by applying this transformation as <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-344d807687f932bcc396d5fafeb311bd_l3.png" class="ql-img-inline-formula " alt="&#92;&#118;&#101;&#99;&#123;&#118;&#125;&#92;&#112;&#114;&#105;&#109;&#101;&#32;&#61;&#32;&#65;&#92;&#118;&#101;&#99;&#123;&#118;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="74" style="vertical-align: 0px;"/>. The above figure shows that the direction of some vectors (shown in red) is not affected by this linear transformation. These vectors are called eigenvectors of the transformation, and uniquely define the square matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-3fae06210cb4529155c990d8d9838d68_l3.png" class="ql-img-inline-formula " alt="&#65;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/>. This unique, deterministic relation is exactly the reason that those vectors are called &#8216;eigenvectors&#8217; (Eigen means &#8216;specific&#8217; in German).</p>
<p>In general, the eigenvector <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-5663d3adf90e26dd70e1f371e6cd6eba_l3.png" class="ql-img-inline-formula " alt="&#92;&#118;&#101;&#99;&#123;&#118;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="13" style="vertical-align: 0px;"/> of a matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-3fae06210cb4529155c990d8d9838d68_l3.png" class="ql-img-inline-formula " alt="&#65;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/> is the vector for which the following holds:<br />
<a name="id3583665669"></a>
<p class="ql-center-displayed-equation" style="line-height: 15px;"><span class="ql-right-eqno"> (1) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-eb4c71b958e218b53b61c59878cbcc8e_l3.png" height="15" width="80" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#65;&#32;&#92;&#118;&#101;&#99;&#123;&#118;&#125;&#32;&#61;&#32;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#32;&#92;&#118;&#101;&#99;&#123;&#118;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>where <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-50bc2c4701f0a0dd472fdd7dad5c47d9_l3.png" class="ql-img-inline-formula " alt="&#92;&#108;&#97;&#109;&#98;&#100;&#97;" title="Rendered by QuickLaTeX.com" height="14" width="11" style="vertical-align: 0px;"/> is a scalar value called the &#8216;eigenvalue&#8217;. This means that the linear transformation <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-3fae06210cb4529155c990d8d9838d68_l3.png" class="ql-img-inline-formula " alt="&#65;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/> on vector <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-5663d3adf90e26dd70e1f371e6cd6eba_l3.png" class="ql-img-inline-formula " alt="&#92;&#118;&#101;&#99;&#123;&#118;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="13" style="vertical-align: 0px;"/> is completely defined by <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-50bc2c4701f0a0dd472fdd7dad5c47d9_l3.png" class="ql-img-inline-formula " alt="&#92;&#108;&#97;&#109;&#98;&#100;&#97;" title="Rendered by QuickLaTeX.com" height="14" width="11" style="vertical-align: 0px;"/>.</p>
<p>We can rewrite equation (<a href="#id3583665669">1</a>) as follows:<br />
<a name="id1398496403"></a>
<p class="ql-center-displayed-equation" style="line-height: 53px;"><span class="ql-right-eqno"> (2) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-ada6ad586377a11090e2a2216fd97c4c_l3.png" height="53" width="162" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#110;&#97;&#114;&#114;&#97;&#121;&#42;&#125; &#65;&#32;&#92;&#118;&#101;&#99;&#123;&#118;&#125;&#32;&#45;&#32;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#32;&#92;&#118;&#101;&#99;&#123;&#118;&#125;&#32;&#61;&#32;&#48;&#32;&#92;&#92;&#32; &#92;&#82;&#105;&#103;&#104;&#116;&#97;&#114;&#114;&#111;&#119;&#32;&#92;&#118;&#101;&#99;&#123;&#118;&#125;&#32;&#40;&#65;&#32;&#45;&#32;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#32;&#73;&#41;&#32;&#61;&#32;&#48;&#44; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#110;&#97;&#114;&#114;&#97;&#121;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>where <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-957d73b755a44351e97c684d0dd6a81a_l3.png" class="ql-img-inline-formula " alt="&#73;" title="Rendered by QuickLaTeX.com" height="14" width="11" style="vertical-align: 0px;"/> is the identity matrix of the same dimensions as <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-3fae06210cb4529155c990d8d9838d68_l3.png" class="ql-img-inline-formula " alt="&#65;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/>.</p>
<p>However, assuming that <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-5663d3adf90e26dd70e1f371e6cd6eba_l3.png" class="ql-img-inline-formula " alt="&#92;&#118;&#101;&#99;&#123;&#118;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="13" style="vertical-align: 0px;"/> is not the null-vector, equation (<a href="#id1398496403">2</a>) can only be defined if <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-94d0d60442ecf418b07344bc1ca1d563_l3.png" class="ql-img-inline-formula " alt="&#40;&#65;&#32;&#45;&#32;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#32;&#73;&#41;" title="Rendered by QuickLaTeX.com" height="23" width="78" style="vertical-align: -6px;"/> is not invertible. If a square matrix is not invertible, that means that its <a href="https://nl.wikipedia.org/wiki/Determinant" title="Matrix determinant calculation" target="_blank">determinant </a>must equal zero. Therefore, to find the eigenvectors of <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-3fae06210cb4529155c990d8d9838d68_l3.png" class="ql-img-inline-formula " alt="&#65;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/>, we simply have to solve the following equation:<br />
<a name="id1043422129"></a>
<p class="ql-center-displayed-equation" style="line-height: 23px;"><span class="ql-right-eqno"> (3) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-d59a2059f63d030aee053e6d6b498960_l3.png" height="23" width="160" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;&#32; &#68;&#101;&#116;&#40;&#65;&#32;&#45;&#32;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#32;&#73;&#41;&#32;&#61;&#32;&#48;&#46; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>In the following sections we will determine the eigenvectors and eigenvalues of a matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-3fae06210cb4529155c990d8d9838d68_l3.png" class="ql-img-inline-formula " alt="&#65;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/>, by solving equation (<a href="#id1043422129">3</a>). Matrix <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-3fae06210cb4529155c990d8d9838d68_l3.png" class="ql-img-inline-formula " alt="&#65;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/> in this example, is defined by:<br />
<a name="id3888381481"></a>
<p class="ql-center-displayed-equation" style="line-height: 51px;"><span class="ql-right-eqno"> (4) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-c29b8a316e5fd2c00ddce343ed09a3a7_l3.png" height="51" width="115" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#65;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#50;&#32;&#38;&#32;&#51;&#32;&#92;&#92;&#32;&#50;&#32;&#38;&#32;&#49;&#32;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#46; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<h2>Calculating the eigenvalues</h2>
<p>To determine the eigenvalues for this example, we substitute <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-3fae06210cb4529155c990d8d9838d68_l3.png" class="ql-img-inline-formula " alt="&#65;" title="Rendered by QuickLaTeX.com" height="14" width="16" style="vertical-align: 0px;"/> in equation (<a href="#id1043422129">3</a>) by equation (<a href="#id3888381481">4</a>) and obtain:</p>
<p class="ql-center-displayed-equation" style="line-height: 51px;"><span class="ql-right-eqno"> (5) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-a0a1263af5ed765bcd4294cd1fb7bcb0_l3.png" height="51" width="230" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#68;&#101;&#116;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#50;&#45;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#38;&#51;&#92;&#92;&#50;&#38;&#49;&#45;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#92;&#101;&#110;&#100;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#61;&#48;&#46; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Calculating the determinant gives:</p>
<p class="ql-center-displayed-equation" style="line-height: 86px;"><span class="ql-right-eqno"> (6) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-3c17ec7b6bfbb228d31d1f39cb0ec80b_l3.png" height="86" width="239" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#38;&#40;&#50;&#45;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#41;&#40;&#49;&#45;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#41;&#32;&#45;&#32;&#54;&#32;&#61;&#32;&#48;&#92;&#92; &#92;&#82;&#105;&#103;&#104;&#116;&#97;&#114;&#114;&#111;&#119;&#32;&#38;&#50;&#32;&#45;&#32;&#50;&#32;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#32;&#45;&#32;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#32;&#45;&#32;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#94;&#50;&#32;&#45;&#54;&#32;&#61;&#32;&#48;&#92;&#92; &#92;&#82;&#105;&#103;&#104;&#116;&#97;&#114;&#114;&#111;&#119;&#32;&#38;&#123;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#125;&#94;&#50;&#32;&#45;&#32;&#51;&#32;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#32;&#45;&#52;&#32;&#61;&#32;&#48;&#46; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>To solve this quadratic equation in <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-50bc2c4701f0a0dd472fdd7dad5c47d9_l3.png" class="ql-img-inline-formula " alt="&#92;&#108;&#97;&#109;&#98;&#100;&#97;" title="Rendered by QuickLaTeX.com" height="14" width="11" style="vertical-align: 0px;"/>, we find the discriminant:</p>
<p class="ql-center-displayed-equation" style="line-height: 26px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-9cfddc6a52bc02141e6aaabf8e7cb89b_l3.png" height="26" width="472" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#68;&#32;&#61;&#32;&#98;&#94;&#50;&#32;&#45;&#52;&#97;&#99;&#32;&#61;&#32;&#40;&#45;&#51;&#41;&#94;&#50;&#32;&#45;&#52;&#42;&#49;&#42;&#40;&#45;&#52;&#41;&#32;&#61;&#32;&#57;&#43;&#49;&#54;&#32;&#61;&#32;&#50;&#53;&#46; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Since the discriminant is strictly positive, this means that two different values for <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-50bc2c4701f0a0dd472fdd7dad5c47d9_l3.png" class="ql-img-inline-formula " alt="&#92;&#108;&#97;&#109;&#98;&#100;&#97;" title="Rendered by QuickLaTeX.com" height="14" width="11" style="vertical-align: 0px;"/> exist:<br />
<a name="id2474539270"></a>
<p class="ql-center-displayed-equation" style="line-height: 104px;"><span class="ql-right-eqno"> (7) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-37219092f3070d9cef6dac1fc00d1cfe_l3.png" height="104" width="280" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;&#32; &#92;&#108;&#97;&#109;&#98;&#100;&#97;&#32;&#95;&#49;&#32;&#38;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#45;&#98;&#32;&#45;&#32;&#92;&#115;&#113;&#114;&#116;&#123;&#68;&#125;&#125;&#123;&#50;&#97;&#125;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#51;&#45;&#53;&#125;&#123;&#50;&#125;&#32;&#61;&#32;&#45;&#49;&#44;&#92;&#92; &#92;&#108;&#97;&#109;&#98;&#100;&#97;&#32;&#95;&#50;&#32;&#38;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#45;&#98;&#32;&#43;&#32;&#92;&#115;&#113;&#114;&#116;&#123;&#68;&#125;&#125;&#123;&#50;&#97;&#125;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#51;&#43;&#53;&#125;&#123;&#50;&#125;&#32;&#61;&#32;&#52;&#46; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>We have now determined the two eigenvalues <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-d28b7f27106b804ac9311012dd46d840_l3.png" class="ql-img-inline-formula " alt="&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#95;&#49;" title="Rendered by QuickLaTeX.com" height="18" width="18" style="vertical-align: -4px;"/> and <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-a90de865b721b1827da7f6e7155ccb3f_l3.png" class="ql-img-inline-formula " alt="&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#95;&#50;" title="Rendered by QuickLaTeX.com" height="17" width="19" style="vertical-align: -3px;"/>. Note that a square matrix of size <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-27211e8b64d0af6bb1c7c805a18af057_l3.png" class="ql-img-inline-formula " alt="&#78;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#78;" title="Rendered by QuickLaTeX.com" height="14" width="64" style="vertical-align: 0px;"/> always has exactly <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-9c99ad944abf4b8313cf07a473add4bf_l3.png" class="ql-img-inline-formula " alt="&#78;" title="Rendered by QuickLaTeX.com" height="14" width="19" style="vertical-align: 0px;"/> eigenvalues, each with a corresponding eigenvector. The eigenvalue specifies the size of the eigenvector.</p>
<h2>Calculating the first eigenvector</h2>
<p>We can now determine the eigenvectors by plugging the eigenvalues from equation (<a href="#id2474539270">7</a>) into equation (<a href="#id3583665669">1</a>) that originally defined the problem. The eigenvectors are then found by solving this system of equations.</p>
<p>We first do this for eigenvalue <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-d28b7f27106b804ac9311012dd46d840_l3.png" class="ql-img-inline-formula " alt="&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#95;&#49;" title="Rendered by QuickLaTeX.com" height="18" width="18" style="vertical-align: -4px;"/>, in order to find the corresponding first eigenvector:</p>
<p class="ql-center-displayed-equation" style="line-height: 51px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-51fb701d729dba46cfec30d0118b0ec6_l3.png" height="51" width="231" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#50;&#38;&#51;&#92;&#92;&#50;&#38;&#49;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#120;&#95;&#123;&#49;&#49;&#125;&#92;&#92;&#120;&#95;&#123;&#49;&#50;&#125;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#61;&#32;&#45;&#49;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#120;&#95;&#123;&#49;&#49;&#125;&#92;&#92;&#120;&#95;&#123;&#49;&#50;&#125;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#46; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Since this is simply the matrix notation for a system of equations, we can write it in its equivalent form:</p>
<p class="ql-center-displayed-equation" style="line-height: 51px;"><span class="ql-right-eqno"> (8) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-3eb2108a126b2454d9a129a952d00f6b_l3.png" height="51" width="200" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#110;&#97;&#114;&#114;&#97;&#121;&#42;&#125; &#92;&#108;&#101;&#102;&#116;&#92;&#123; &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#114;&#114;&#97;&#121;&#125;&#123;&#108;&#114;&#125; &#50;&#120;&#95;&#123;&#49;&#49;&#125;&#32;&#43;&#32;&#51;&#120;&#95;&#123;&#49;&#50;&#125;&#32;&#61;&#32;&#45;&#120;&#95;&#123;&#49;&#49;&#125;&#92;&#92; &#50;&#120;&#95;&#123;&#49;&#49;&#125;&#32;&#43;&#32;&#120;&#95;&#123;&#49;&#50;&#125;&#32;&#61;&#32;&#45;&#120;&#95;&#123;&#49;&#50;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#114;&#114;&#97;&#121;&#125; &#92;&#114;&#105;&#103;&#104;&#116;&#46; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#110;&#97;&#114;&#114;&#97;&#121;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>and solve the first equation as a function of <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-6d4ff917b6f3318e7e751d763f714ea0_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#123;&#49;&#50;&#125;" title="Rendered by QuickLaTeX.com" height="13" width="28" style="vertical-align: -4px;"/>, resulting in:<br />
<a name="id2280642976"></a>
<p class="ql-center-displayed-equation" style="line-height: 13px;"><span class="ql-right-eqno"> (9) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-26c85379d54fa989997f8f646a31a747_l3.png" height="13" width="108" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;&#32; &#120;&#95;&#123;&#49;&#49;&#125;&#32;&#61;&#32;&#45;&#120;&#95;&#123;&#49;&#50;&#125;&#46; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Since an eigenvector simply represents an orientation (the corresponding eigenvalue represents the magnitude), all scalar multiples of the eigenvector are vectors that are parallel to this eigenvector, and are therefore equivalent (If we would normalize the vectors, they would all be equal). Thus, instead of further solving the above system of equations, we can freely chose a real value for either <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-6bfc99a3e13267a369fcf851315468ad_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#123;&#49;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="13" width="27" style="vertical-align: -4px;"/> or <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-6d4ff917b6f3318e7e751d763f714ea0_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#123;&#49;&#50;&#125;" title="Rendered by QuickLaTeX.com" height="13" width="28" style="vertical-align: -4px;"/>, and determine the other one by using equation (<a href="#id2280642976">9</a>).</p>
<p>For this example, we arbitrarily choose <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-eae7bb719d85b520859b4efcdb2423f3_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#123;&#49;&#50;&#125;&#32;&#61;&#32;&#49;" title="Rendered by QuickLaTeX.com" height="19" width="66" style="vertical-align: -4px;"/>, such that <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-71e71de9bed7d8d8c8b2268d53e98c33_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#123;&#49;&#49;&#125;&#61;&#45;&#49;" title="Rendered by QuickLaTeX.com" height="19" width="82" style="vertical-align: -4px;"/>. Therefore, the eigenvector that corresponds to eigenvalue <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-1b6489b3ba211bcae4e11ed33cd40d75_l3.png" class="ql-img-inline-formula " alt="&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#95;&#49;&#32;&#61;&#32;&#45;&#49;" title="Rendered by QuickLaTeX.com" height="19" width="73" style="vertical-align: -4px;"/> is</p>
<p class="ql-center-displayed-equation" style="line-height: 51px;"><span class="ql-right-eqno"> (10) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-750ab155a0cb7a251a9a730f899fa4e6_l3.png" height="51" width="105" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#118;&#101;&#99;&#123;&#118;&#125;&#95;&#49;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#45;&#49;&#32;&#92;&#92;&#32;&#49;&#32;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#46; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<h2>Calculating the second eigenvector</h2>
<p>Calculations for the second eigenvector are similar to those needed for the first eigenvector;<br />
We now substitute eigenvalue <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-0eb3579cfe7e895b8986141810327dcf_l3.png" class="ql-img-inline-formula " alt="&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#95;&#50;&#61;&#52;" title="Rendered by QuickLaTeX.com" height="18" width="58" style="vertical-align: -3px;"/> into equation (<a href="#id3583665669">1</a>), yielding:</p>
<p class="ql-center-displayed-equation" style="line-height: 51px;"><span class="ql-right-eqno"> (11) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-4405b5dcc9364e191550b259ee786731_l3.png" height="51" width="231" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#50;&#38;&#51;&#92;&#92;&#50;&#38;&#49;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#120;&#95;&#123;&#50;&#49;&#125;&#92;&#92;&#120;&#95;&#123;&#50;&#50;&#125;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#61;&#32;&#52;&#32;&#42;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#120;&#95;&#123;&#50;&#49;&#125;&#92;&#92;&#120;&#95;&#123;&#50;&#50;&#125;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#46; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Written as a system of equations, this is equivalent to:</p>
<p class="ql-center-displayed-equation" style="line-height: 51px;"><span class="ql-right-eqno"> (12) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-1b3e60a4a1f4deb124f3057544909434_l3.png" height="51" width="195" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#110;&#97;&#114;&#114;&#97;&#121;&#42;&#125; &#92;&#108;&#101;&#102;&#116;&#92;&#123; &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#114;&#114;&#97;&#121;&#125;&#123;&#108;&#114;&#125; &#50;&#120;&#95;&#123;&#50;&#49;&#125;&#32;&#43;&#32;&#51;&#120;&#95;&#123;&#50;&#50;&#125;&#32;&#61;&#32;&#52;&#120;&#95;&#123;&#50;&#49;&#125;&#92;&#92; &#50;&#120;&#95;&#123;&#50;&#49;&#125;&#32;&#43;&#32;&#120;&#95;&#123;&#50;&#50;&#125;&#32;&#61;&#32;&#52;&#120;&#95;&#123;&#50;&#50;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#114;&#114;&#97;&#121;&#125; &#92;&#114;&#105;&#103;&#104;&#116;&#46; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#110;&#97;&#114;&#114;&#97;&#121;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Solving the first equation as a function of <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-413ecbc275b9fdd5f2b4d8ea66360485_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#123;&#50;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="13" width="27" style="vertical-align: -4px;"/> resuls in: </p>
<p class="ql-center-displayed-equation" style="line-height: 44px;"><span class="ql-right-eqno"> (13) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-3080c6b78e3d7b7cb8ea390a77d4c950_l3.png" height="44" width="100" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#120;&#95;&#123;&#50;&#50;&#125;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#51;&#125;&#123;&#50;&#125;&#120;&#95;&#123;&#50;&#49;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>We then arbitrarily choose <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-f7a14402224c1d1440ed8ef030362f24_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#123;&#50;&#49;&#125;&#61;&#50;" title="Rendered by QuickLaTeX.com" height="19" width="67" style="vertical-align: -4px;"/>, and find <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-37b1bac871a4279c4a118181ba22808b_l3.png" class="ql-img-inline-formula " alt="&#120;&#95;&#123;&#50;&#50;&#125;&#61;&#51;" title="Rendered by QuickLaTeX.com" height="18" width="67" style="vertical-align: -3px;"/>. Therefore, the eigenvector that corresponds to eigenvalue <img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-a8e1382a3ac364fffbadd637d326da6a_l3.png" class="ql-img-inline-formula " alt="&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#95;&#50;&#32;&#61;&#32;&#52;" title="Rendered by QuickLaTeX.com" height="18" width="58" style="vertical-align: -3px;"/> is</p>
<p class="ql-center-displayed-equation" style="line-height: 51px;"><span class="ql-right-eqno"> (14) </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://www.visiondummy.com/wp-content/ql-cache/quicklatex.com-388e29a06781d5b817855b294db4ae09_l3.png" height="51" width="89" class="ql-img-displayed-equation " alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#118;&#101;&#99;&#123;&#118;&#125;&#95;&#50;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#51;&#32;&#92;&#92;&#32;&#50;&#32;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#46; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<h2>Conclusion</h2>
<p>In this article we reviewed the theoretical concepts of eigenvectors and eigenvalues. These concepts are of great importance in many techniques used in computer vision and machine learning, such as dimensionality reduction by means of PCA, or face recognition by means of EigenFaces.</p>
<p><strong>If you&#8217;re new to this blog, don&#8217;t forget to subscribe, or <a href="https://twitter.com/vincent_spruyt" title="Follow me on Twitter!" target="_blank">follow me on twitter</a>!</strong><br />


<!-- Form created by Optin Forms plugin by Codeleon: create beautiful optin forms with ease! -->
<!-- http://codeleon.com/products/optin-forms/ -->
<div id="optinforms-form5-container" ><form method="post" target="_blank" action="http://visiondummy.us10.list-manage.com/subscribe/post?u=c435905e10ead915f3917d694&id=bbdfb33a9f"><div id="optinforms-form5" style="background:#ffffff;"><div id="optinforms-form5-container-left"><div id="optinforms-form5-title" style="font-family:News Cycle; font-size:24px; line-height:24px; color:#fd4326">JOIN MY NEWSLETTER</div><!--optinforms-form5-title--><input type="text" id="optinforms-form5-name-field" name="FNAME" placeholder="Enter Your Name" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#000000" /><input type="text" id="optinforms-form5-email-field" name="EMAIL" placeholder="Enter Your Email" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#000000" /><input type="submit" name="submit" id="optinforms-form5-button" value="SUBSCRIBE" style="font-family:Arial, Helvetica, sans-serif; font-size:16px; color:#FFFFFF; background-color:#fd4326" /></div><!--optinforms-form5-container-left--><div id="optinforms-form5-container-right"><div id="optinforms-form5-subtitle" style="font-family:Georgia; font-size:16px; color:#444444">Receive my newsletter to get notified when new articles and code snippets become available on my blog!</div><!--optinforms-form5-subtitle--><div id="optinforms-form5-disclaimer" style="font-family:Georgia, Times New Roman, Times, serif; font-size:14px; color:#727272">We all hate spam. Your email address will not be sold or shared with anyone else.</div><!--optinforms-form5-disclaimer--></div><!--optinforms-form5-container-right--><div class="clear"></div></div><!--optinforms-form5--><div class="clear"></div></form></div><!--optinforms-form5-container--><div class="clear"></div>
<!-- / Optin Forms -->

<style type='text/css'></style></p>
<p>The post <a rel="nofollow" href="https://www.visiondummy.com/2014/03/eigenvalues-eigenvectors/">What are eigenvectors and eigenvalues?</a> appeared first on <a rel="nofollow" href="https://www.visiondummy.com">Computer vision for dummies</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.visiondummy.com/2014/03/eigenvalues-eigenvectors/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk: enhanced
Database Caching using disk
Object Caching 1071/1085 objects using disk

 Served from: www.visiondummy.com @ 2026-05-02 10:33:16 by W3 Total Cache -->