






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Principal Components Analysis
Chapter 1
This tutorial is designed to give the reader an understanding of Principal Components
Analysis (PCA). PCA is a useful statistical technique that has found application in
field such as face recognition and image compression, and is a common technique for
findin patterns in data of high dimension.
Before getting to a description of PCA, this tutorial firs introduces mathematical
concepts that will be used in PCA. It covers standard deviation, covariance, eigenvec-
tors and eigenvalues. This background knowledge is meant to make the PCA section
very straightforward, but can be skipped if the concepts are already familiar.
There are examples all the way through this tutorial that are meant to illustrate the
concepts being discussed. If further information is required, the mathematics textbook
“Elementary Linear Algebra 5e” by Howard Anton, Publisher John Wiley & Sons Inc,
ISBN 0-471-85223-6 is a good source of information regarding the mathematical back-
ground.
1
of some bigger population. There is a reference later in this section pointing to more
information about samples and populations.
Here’s an example set:
I could simply use the symbol
to refer to this entire set of numbers. If I want to
refer to an individual number in this data set, I will use subscripts on the symbol
to
indicate a specifi number. Eg.
refers to the 3rd number in
, namely the number
is the firs number in the sequence, not
like you may see in some
textbooks. Also, the symbol will be used to refer to the number of elements in the
set
There are a number of things that we can calculate about a data set. For example,
we can calculate the mean of the sample. I assume that the reader understands what the
mean of a sample is, and will only give the formula:
Notice the symbol
(said “X bar”) to indicate the mean of the set
. All this formula
says is “Add up all the numbers and then divide by how many there are”.
Unfortunately, the mean doesn’t tell us a lot about the data except for a sort of
middle point. For example, these two data sets have exactly the same mean (10), but
are obviously quite different:
So what is different about these two sets? It is the spread of the data that is different.
The Standard Deviation (SD) of a data set is a measure of how spread out the data is.
How do we calculate it? The English definitio of the SD is: “The average distance
from the mean of the data set to a point”. The way to calculate it is to compute the
squares of the distance from each data point to the mean of the set, add them all up,
divide by .-
, and take the positive square root. As a formula:
Where
is the usual symbol for standard deviation of a sample. I hear you asking “Why
are you using
and not ?”. Well, the answer is a bit complicated, but in general,
if your data set is a sample data set, ie. you have taken a subset of the real-world (like
surveying 500 people about the election) then you must use
because it turns out
that this gives you an answer that is closer to the standard deviation that would result
if you had used the entire population, than if you’d used . If, however, you are not
calculating the standard deviation for a sample, but for an entire population, then you
should divide by instead of
. For further reading on this topic, the web page
http://mathcentral.uregina.ca/RR/database/RR.09.95/weston2.html describes standard
deviation in a similar way, and also provides an example experiment that shows the
3
Set 1:
0 -10 100
8 -2 4
12 2 4
20 10 100
Total 208
Divided by (n-1) 69.
Square Root 8.
Set 2:
8 -2 4
9 -1 1
11 1 1
12 2 4
Total 10
Divided by (n-1) 3.
Square Root 1.
Table 2.1: Calculation of standard deviation
difference between each of the denominators. It also discusses the difference between
samples and populations.
So, for our two data sets above, the calculations of standard deviation are in Ta-
ble 2.1.
And so, as expected, the firs set has a much larger standard deviation due to the
fact that the data is much more spread out from the mean. Just as another example, the
data set:
also has a mean of 10, but its standard deviation is 0, because all the numbers are the
same. None of them deviate from the mean.
2.1.2 Variance
Variance is another measure of the spread of data in a data set. In fact it is almost
identical to the standard deviation. The formula is this:
4
includegraphicscovPlot.ps
Figure 2.1: A plot of the covariance data showing positive relationship between the
number of hours studied against the mark received
It is exactly the same except that in the second set of brackets, the
’s are replaced by
’s. This says, in English, “For each data item, multiply the difference between the <
value and the mean of < , by the the difference between the = value and the mean of =.
Add all these up, and divide by
”.
How does this work? Lets use some example data. Imagine we have gone into the
world and collected some 2-dimensional data, say, we have asked a bunch of students
how many hours in total that they spent studying COSC241, and the mark that they
received. So we have two dimensions, the firs is the H dimension, the hours studied,
and the second is the I dimension, the mark received. Figure 2.2 holds my imaginary
data, and the calculation of
, the covariance between the Hours of study
done and the Mark received.
So what does it tell us? The exact value is not as important as it’s sign (ie. positive
or negative). If the value is positive, as it is here, then that indicates that both di-
mensions increase together , meaning that, in general, as the number of hours of study
increased, so did the fina mark.
If the value is negative, then as one dimension increases, the other decreases. If we
had ended up with a negative covariance here, then that would have said the opposite,
that as the number of hours of study increased the the fina mark decreased.
In the last case, if the covariance is zero, it indicates that the two dimensions are
independent of each other.
The result that mark given increases as the number of hours studied increases can
be easily seen by drawing a graph of the data, as in Figure 2.1.3. However, the luxury
of being able to visualize data is only available at 2 and 3 dimensions. Since the co-
variance value can be calculated between any 2 dimensions in a data set, this technique
is often used to fin relationships between dimensions in high-dimensional data sets
where visualisation is difficult
You might ask “is
equal to
”? Well, a quick look at the for-
mula for covariance tells us that yes, they are exactly the same since the only dif-
ference between
and
is that
is replaced by