to refresh some knowledge.
Geometry
- Given the two points and , give an equation for the line through these two points. The equation should have the form:
Thereβs the line equation given by two points:
so after I plug in the values, I get:
If we substitute, the solution would be
- Make a plot of the line and the vector . The direction of is called the positive side of the line.
- Consider the point . Is this point on the positive side or negative side of the line? Also compute for this point.
I only need to plug the point into the line equation and see if itβs positive or negative.
β on the positive side.
- Show that the distance of the point to the line is equal to:
The question is literally ask me to derive the formula, not simply use it. This is where I need to use vectors.
The concept is: move from the point along the normal direction until you hit the line; the distance moved is the answer.
What I know is that is perpendicular to the line. Therefore, I need to make use of projections:
Letβs say that the point hits the line in point of coordinates . A distance from a point to a line is the perpendicular from that point on the line. That means we have the same direction as , since itβs also perpendicular on the line.
Since the point must lie on the line, we can compute . Also, to go from straight to the line, I must move along the direction . Any point along that direction, starting from can be written as:
start point + (scalar) (direction) =
Ξ» is just βhow farβ I move along that direction β could be positive, negative, or zero.
Plug into the line equation:
Since , the distance between the point and is:
q.e.d.
- What is the distance of the line to the origin and how can this be computed in terms of ?
I simply need to use the formula from the last question, and replace for
Calculus
- Show that the derivative of w.r.t is given by:
just know that
- Show that:
- for large, i.e. , . I havenβt done limits since highschool. is this really ML?..
- for ,
- for small, i.e. ,
- for large,
- From before, assume . Show that the partial derivative of w.r.t is given by:
I already know . And if I look at the line equation from above, . Therefore, we have the equation.
- Once again assume that . Show that:
- the gradient of w.r.t. the vector (denoted is given by , where is the vector .
i see that each partial derivative corresponds to that vector: , , .
- Show that:
- if is positive, then for and other weights and input constant,
Since , with constants and , as we get .
I showed in the second subpoint that as , . The term from above would reduce to , where is a positive constant, which does not affect the end result of 0.
- if is negative, then for ,
Since , with constants and , as we get .
From part 2, as , I showed that . So .
Statistics and Probability theory
Consider .
- Compute the sample mean of .
I would ASSUME itβs the overall mean over and axes:
- Compute the covariance matrix of .
Should be a matrix since we have two dimensions. We use the formula:
Apparently, this is the biased (maximum likelihood estimate) β on average it slightly underestimates the true variance, because I used the data itself to compute . If they said something like βassume this is the full populationβ, or βmaximum likelihood estimate ofβ¦β, then I use .
Therefore, dividing by corrects that bias. Apparently this is the norm in libraries as well.
So the answer is:
- Compute, based on the covariance matrix, the correlation between (the first component) and .
Covariance tells me direction of the relationship but its size depends on the units/scale of and β so itβs not comparable across datasets. Correlation fixes this by standardizing.
correlation = "covariance after removing the scale"
Start with the covariance:
This in itself mixes the units of and (e.g. is in meters, is in kg), then we would have a meter-kg meaningless scale. To remove the scale dependence, standardize each variable first β divide by its own deviation:
Then the correlation is just the covariance of the standardized variables:
By definition, covaiance of any two variables is:
But I standardized the data. has mean 0. Same for . So .
- remember that . So get them directly from the previous point.
- Compute the eigenvalues and eigenvectors of the covariance matrix of part b. What is the covariance matrix if we transform the data points into coordinates w.r.t these eigenvectors?
From ML Preliminaries, we call e an eigenvector and the corresponding eigenvalue of matrix A if:
So we start with this formula:
I want a nonzero eigenvector . The equation from above has nonzero solutions only when the matrix is singular (non-invertible) β otherwise the solution would be .
A matrix is singular exactly when its determinant is 0. Also called characteristic equation.
So I use it for the covariance matrix
Now for the eigenvectors, this gives a system of equations to solve for . So from the formula above:
So the equation becomes:
These two are just multiples of each other (thatβs what βsingular matrixβ means β determinant 0), so I only need one of them. The first yields
Now I need to normalize. Itβs convention so eigenvectors are comparable/unique:
So normalized would be:
eigenvectors are only defined up to sign; both and are equally valid since is also a solution to the equation above.
Doing the same step for yields .
One can see the eigenvectors have the same values inside, just swapped in position, with one sign flipped.
Eigenvectors of a symmetric matrix are orthogonal β perpendicular to each other. For a 2D vector, if I have a vector , a perpendicular vector is always or .
- Now the second part: what is the cov matrix if we transform the data points into coordinates w.r.t these eigenvectors?
I build a matrix whose columns are the eigenvectors:
To express a data point (as a column vector, mean-centered) in the new coordinate system, project it onto each eigenvector using the dot product:
complete hereβ¦