Download Internal Report Title - Current students

Transcript
The cost and the minimum projected length are numbers which quantify how 'good'
the projection is for the given data (closer to 1 the better). The two entries of the
matrix W can be interpreted as the x and y components of a vector which points in the
direction of the straight line onto which the data is being projected. To project the
data points onto this line, each 2D point is multiplied by the transpose of W. For
example if X is a two dimensional data point then X’ = W.transpose() * X, where X’ will
be a one dimensional data point (a position on the line).
This calculation is performed for every given two dimensional point. The result of these
calculations is included in the last part of the program’s output as shown below.
The line representing the given points in one dimensional space should pass through
the origin of the axes. The equation of the line is of type y=a (x) where “a” is given
from the two elements of the matrix W such as (a=W1/W0). W0 and W1 are the first
and second elements of the matrix W respectively. If the W0 has a value of zero, then
the line is drawn on top of the Y axis.
The two end positions of the visible part of the line, inside the graph, are calculated
using the equations y1 = a*(x_max) and y2 = a*(- x_max) where x_max is the maximum
value displayed on the X axis. The coordinates of the two end positions will then be
(x_max, y1) and (-x_max, y2). When y1 and y2 are greater than y_max (maximum value
on Y axis) then the end positions are not on the top and bottom edges of the graph but
on the left and right ones instead. In this case the end positions are calculated using
the equations x1 = (y_max)/a and x2 = (-y_max)/a. The coordinates of the end
positions will then be (x1, y_max) and (x2, -y_max). The line is then displayed inside
the graph from one point to the other. The function addPoint() which is responsible to
draw the projection line after each new point addition is available in appendix A.3.
68