Linear Algebra and Geometric Interpretations

Dot Product

  • Corresponds to the angle between two vectors.
  • Given two vectors, take the transpose of the first vector (making it a row vector).
  • Multiply the transposed vector with the second vector.
  • This involves multiplying corresponding terms in each vector and summing the results.
  • The dot product results in a single number (scalar).

Geometric Interpretation

  • In two dimensions, consider vector xx and vector yy.
  • θx\theta_x is the angle vector xx subtends on the horizontal axis.
  • x<em>1=∣∣x∣∣</em>2cos⁡(θ<em>x)x<em>1 = ||x||</em>2 \cos(\theta<em>x), where ∣∣x∣∣</em>2||x||</em>2 is the two-norm (magnitude) of xx.
  • x<em>2=∣∣x∣∣</em>2sin⁡(θx)x<em>2 = ||x||</em>2 \sin(\theta_x)
  • Similarly, for vector yy: y<em>1=∣∣y∣∣</em>2cos⁡(θ<em>y)y<em>1 = ||y||</em>2 \cos(\theta<em>y) and y</em>2=∣∣y∣∣<em>2sin⁡(θ</em>y)y</em>2 = ||y||<em>2 \sin(\theta</em>y)
  • x<em>1y</em>1+x<em>2y</em>2=∣∣x∣∣<em>2∣∣y∣∣</em>2cos⁡(θ<em>x)cos⁡(θ</em>y)+∣∣x∣∣<em>2∣∣y∣∣</em>2sin⁡(θ<em>x)sin⁡(θ</em>y)x<em>1y</em>1 + x<em>2y</em>2 = ||x||<em>2 ||y||</em>2 \cos(\theta<em>x) \cos(\theta</em>y) + ||x||<em>2 ||y||</em>2 \sin(\theta<em>x) \sin(\theta</em>y)
  • This simplifies to ∣∣x∣∣<em>2∣∣y∣∣</em>2cos⁡(θ<em>x−θ</em>y)||x||<em>2 ||y||</em>2 \cos(\theta<em>x - \theta</em>y), which is the product of magnitudes times the cosine of the angle between them.
  • If the angle is zero, the dot product is the product of the magnitudes.
  • If the angle is 90 degrees (orthogonal), the dot product is zero, since cos⁡(90∘)=0\cos(90^\circ) = 0.
  • When vectors are normalized (two-norm equals one), the dot product measures the angle between them.

Geometric Interpretation with Unit Vector

  • If one vector is a unit vector (e.g., β\beta) and the other is not (e.g., xx), the dot product xTβx^T \beta has a geometric meaning.
  • xTβ=∣∣x∣∣<em>2∣∣β∣∣</em>2cos⁡(θ)x^T \beta = ||x||<em>2 ||\beta||</em>2 \cos(\theta), where ∣∣β∣∣2=1||\beta||_2 = 1.
  • So, xTβ=∣∣x∣∣2cos⁡(θ)x^T \beta = ||x||_2 \cos(\theta)
  • This represents the length of the projection of xx onto β\beta.
  • Consider a right triangle formed by dropping a perpendicular from point xx onto the β\beta axis.
  • The dot product gives the length of the base of this triangle.
  • Projections are fundamental in many reasoning tasks involving points.
  • This concept is crucial when discussing hyperplanes and using linear surfaces for class separation.

Matrices as Collections of Points

  • A matrix can be viewed as a collection of points in high-dimensional space, where each column is a point.

Pre-multiplying with a Unit Vector

  • Consider a unit vector β\beta and a matrix AA.
  • Pre-multiplying AA with βT\beta^T (i.e., βTA\beta^T A) has a geometric interpretation.
  • Algebraically, if AA has columns a<em>1,a</em>2,…a<em>1, a</em>2, \dots, then βTA\beta^T A results in a row vector: [βTa<em>1,βTa</em>2,… ][\beta^T a<em>1, \beta^T a</em>2, \dots].
  • Each element βTa<em>i\beta^T a<em>i is the projection of point a</em>ia</em>i onto the unit vector β\beta.
  • This operation projects all points in the matrix onto a single vector β\beta, effectively looking at those points in that dimension.
  • This principle underlies Principal Component Analysis (PCA).

Matrix-Vector Multiplication Geometry

  • Given a matrix AA and a vector xx, the product AxAx results in a new vector.
  • If AA is n×kn \times k and xx is k×1k \times 1, the result is an n×1n \times 1 vector.
  • Each entry in the resulting vector is a dot product of a row of AA with the vector xx.
  • Alternatively, this can be viewed as a linear combination of the columns of AA, where the coefficients are the entries of xx.
  • Ax=x<em>1a</em>1+x<em>2a</em>2+⋯+x<em>ka</em>kAx = x<em>1 a</em>1 + x<em>2 a</em>2 + \dots + x<em>k a</em>k, where a<em>ia<em>i are the columns of AA and x</em>ix</em>i are the elements of xx.
  • Geometrically, you take each column vector of AA, scale it by the corresponding entry in xx, and then sum all the scaled vectors to get a new point.

Vector Space and Rank

  • If a matrix AA has only two columns, all linear combinations of these columns will lie in the same plane.
  • The span of all possible linear combinations of the columns of AA forms a vector space.
  • The rank of the vector space is the number of orthogonal dimensions covered by the space.
  • If all points lie on a plane, the rank is 2, even if the original space is higher-dimensional.
  • The vector space is the set of all points that can be reached by AxAx for all possible choices of xx.

Outer Product Geometry

  • The outer product of two vectors xx and yy (i.e., xyTxy^T) results in a matrix.
  • If xx is n×1n \times 1 and yy is 1×m1 \times m, then xyTxy^T is an n×mn \times m matrix.
  • When m=1m = 1, xyTxy^T is just the vector xx scaled by the scalar y1y_1.
  • If yy has multiple entries (y<em>1,y</em>2,…,ymy<em>1, y</em>2, \dots, y_m), each column of the resulting matrix is a scaled version of the vector xx.
  • All columns of the matrix will lie on the same line passing through the origin.
  • This matrix has a rank of 1 because its vector space is confined to a single dimension.

Key Takeaways

  • Vectors are points in high-dimensional space.
  • Dot product and projections.
  • Matrices as collections of points.
  • Matrix-vector multiplication.
  • Vector space and rank.
  • Emphasis on geometric intuition.

Supervised Classification and Hyperplanes

  • Given two classes of points, if they are separated in space, the goal is to find a surface that separates them.
  • In two dimensions, this is a line; in three dimensions, it's a plane; in n dimensions, it's a hyperplane.
  • A hyperplane is an (n−1)(n-1)-dimensional surface.
  • There is a line orthogonal to all points on the hyperplane in an n-dimensional space.
  • The unit vector β\beta normal to the hyperplane, and the shortest distance from the hyperplane to the origin β0\beta_0, define the hyperplane.

Hyperplane Definition

  • Let x<em>1x<em>1 be a point on the hyperplane. Then, βTx</em>1=β0\beta^T x</em>1 = \beta_0.
  • The projection of any point on the hyperplane onto β\beta is always β0\beta_0.
  • The hyperplane LL is the set of all points xx such that βTx=β0\beta^T x = \beta_0.
  • In two dimensions, this generalizes the equation of a line.

Distance from a Point to a Hyperplane

  • For a point xx not on the hyperplane, the shortest distance from xx to the hyperplane is given by ∣βTx−β0∣|\beta^T x - \beta_0|.
  • βTx\beta^T x is the projection of xx onto β\beta.
  • Subtracting β0\beta_0 gives the signed distance to the hyperplane.
  • If βTx−β0=0\beta^T x - \beta_0 = 0, the point lies on the hyperplane.
  • The sign of βTx−β0\beta^T x - \beta_0 indicates which side of the hyperplane the point lies on.
  • If two points have the same sign for βTx−β0\beta^T x - \beta_0, they are on the same side; if they have opposite signs, they are on opposite sides.

Applications in Bioinformatics

  • Gene expression or proteomics experiments result in an expression matrix.
  • Samples fall into classes (e.g., ALL and AML leukemia).
  • The problem is to predict the class of a new sample based on its expression values (supervised classification).
  • Another problem is to determine if points intrinsically separate into different classes (unsupervised learning).

Single-Cell Data Analysis

  • Single-cell data provides expression vectors for individual cells.
  • The goal is to cluster cells by type and project them into lower dimensions for visualization.
  • Each cell type should ideally form a distinct cluster.
  • This allows for comparison of cell compositions between samples.

Dimensionality Reduction

  • Given a matrix (collection of points), represent each sample by a single point in a lower dimension.
  • Algebraically, find a direction β\beta and pre-multiply the matrix by βT\beta^T.
  • Geometrically, project all points onto the direction β\beta.

Principal Component Analysis (PCA) Intuition

  • The goal is to project points in a way that preserves as much information as possible.
  • If points are projected onto a direction where they cluster tightly, information is lost.
  • The best direction is the one along which the projected points have the maximum variance.
  • Find β\beta such that the variance of the projected points is maximized. This β\beta is the principal component.

PCA Algebra

  • Compute the mean vector m of all data points.
  • Subtract the mean from each data point to center the data at the origin: x<em>i←x</em>i−mx<em>i \leftarrow x</em>i - m.
  • Project the centered data points onto β\beta: βT(xi−m)\beta^T (x_i - m).
  • These projected points have a mean of zero.

Variance Calculation

  • The sample variance of the projected points is ∑<em>i(βT(x</em>i−m))2\sum<em>i (\beta^T (x</em>i - m))^2.
  • The goal is to maximize this variance over all choices of the unit vector β\beta.

Maximizing Variance

  • ∑<em>i(βT(x</em>i−m))2=∑<em>iβT(x</em>i−m)(x<em>i−m)Tβ=βTSβ\sum<em>i (\beta^T (x</em>i - m))^2 = \sum<em>i \beta^T (x</em>i - m) (x<em>i - m)^T \beta = \beta^T S \beta, where S=∑</em>i(x<em>i−m)(x</em>i−m)TS = \sum</em>i (x<em>i - m) (x</em>i - m)^T is the covariance matrix.
  • The problem becomes: Maximize βTSβ\beta^T S \beta subject to ∣∣β∣∣2=1||\beta||_2 = 1.