Docsity

Notes on Linear Algebra in Machine Learning | CS 5350, Study notes of Computer Science

Toggle sidebar
bg1
Machine Learning (CS 5350/CS 6350) 11 Jan 2006
Math refresher
Linear algebra
Why linear algebra? Represent a set of linear equations:
4x1+−5x2=−13 (1)
−2x1+ 3x2=9 (2)
can be represented as:
Ax =b, A =4−5
−2 3 , b =13
−9(3)
Now we can solve the set of equations by solving for x.
Additionally, provides convenient notation. Will often write Piwixi; it is shorter (and easier to work with)
to write w>xor hw, xior (w·x) for this (we will stick with the first, but any is okay) . . . Matlab: w’x.
Notation:
1. Matrices are capitalized, A∈RM×Nmeans an M-row, N-column matrix.
2. Vectors will be column vectors, so that x∈RMmeans x∈R1×M. To get a row vector, we write x>.
3. If xis a vector, then xmis the mth element of x(a scalar).
4. If Ais a matrix, then Am,n or Amn (when clear) is the mth row, nth column scalar from A.
5. If Ais a matrix, then A:,n is the column vector from the nth column of Aand Am,:is the row vector
from the mth row of A.
Simple operations:
1. A∈RM×Nand α∈R, then A+αis defined by (A+α)mn =Amn +αand (αA)mn is αAmn.
Subtraction and division similar.
2. A∈RM×Nand B∈RN×Pmeans C=AB ∈RM×P, with Cmp =PnAmnBnp =Am,:B:,p .
3. Vectors x∈RMand y∈RM,x>y=Pmxmymis a scalar.
4. Vectors x∈RMand y∈RN,xy>∈RM×Ndefined by (xy>)mn =xmyn.
5. Multiplication is associative and distributive but not commutative: (AB)C=A(BC ) and A(B+C) =
AB +AC, but it is possible that AB 6=B A.
Additional definitions:
1
pf3
pf4
pf5

Partial preview of the text

Download Notes on Linear Algebra in Machine Learning | CS 5350 and more Study notes Computer Science in PDF only on Docsity!

Machine Learning (CS 5350/CS 6350) 11 Jan 2006

Math refresher

Linear algebra

Why linear algebra? Represent a set of linear equations:

4 x 1 + − 5 x 2 = − 13 (1) − 2 x 1 + 3x 2 =9 (2)

can be represented as:

Ax = b, A =

[ 4 − 5

]

, b =

[ 13

]

Now we can solve the set of equations by solving for x. Additionally, provides convenient notation. Will often write ∑ i wixi; it is shorter (and easier to work with) to write w>x or 〈w, x〉 or (w · x) for this (we will stick with the first, but any is okay)... Matlab: w’x. Notation:

  1. Matrices are capitalized, A ∈ RM^ ×N^ means an M -row, N -column matrix.
  2. Vectors will be column vectors, so that x ∈ RM^ means x ∈ R^1 ×M^. To get a row vector, we write x>.
  3. If x is a vector, then xm is the mth element of x (a scalar).
  4. If A is a matrix, then Am,n or Amn (when clear) is the mth row, nth column scalar from A.
  5. If A is a matrix, then A:,n is the column vector from the nth column of A and Am,: is the row vector from the mth row of A.

Simple operations:

  1. A ∈ RM^ ×N^ and α ∈ R, then A + α is defined by (A + α)mn = Amn + α and (αA)mn is αAmn. Subtraction and division similar.
  2. A ∈ RM^ ×N^ and B ∈ RN^ ×P^ means C = AB ∈ RM^ ×P^ , with Cmp = ∑ n AmnBnp = Am,:B:,p.
  3. Vectors x ∈ RM^ and y ∈ RM^ , x>y = ∑ m xmym is a scalar.
  4. Vectors x ∈ RM^ and y ∈ RN^ , xy>^ ∈ RM^ ×N^ defined by (xy>)mn = xmyn.
  5. Multiplication is associative and distributive but not commutative: (AB)C = A(BC) and A(B + C) = AB + AC, but it is possible that AB 6 = BA.

Additional definitions:

1

  1. Identity matrix, I ∈ RN^ ×N^ defined by Imn = 1m=n. For all A (of appr. size), AI = IA = A.
  2. Diagonal matrix, D = diag(d) ∈ RN^ ×N^ for d ∈ RN^ defined by Dmn = 1m=ndm.
  3. Transpose, if A ∈ RM^ ×N^ then A>^ ∈ RN^ ×M^ with (A>)nm = Amn. Holds: (A>)>^ = A, (AB)>^ = B>A> and (A + B)>^ = A>^ + B>.
  4. Symmatric, square A is symmatric if A = A>. Often SN^ = {A ∈ RN^ ×N^ : A is symmetric}.
  5. Trace, the sum of the diagonals: tr A = ∑ n Ann for A ∈ RN^ ×N^.

Norms:

  1. For a vector x, the norm of x, ||x|| is typically the Euclidean, or ` 2 norm: ||x||^22 = x>x.
  2. `p norm is ||x||pp = ∑ n |xi|p
  3. Infinite norm: ||x||∞ = maxi |xi|.

Inverse:

  1. A ∈ RN^ ×N^ , and A invertible, then A−^1 is unique such that A−^1 A = AA−^1 = I.
  2. A is invertible if all of its rows (or columns) are linearly independent.
  3. (A−^1 )−^1 = A, (AB)−^1 = B−^1 A−^1 , (A−^1 )>^ = (A>)−^1.
  4. If Ax = b then x = A−^1 b.

Determinant

  1. AinRN^ ×N^ , then det A ∈ R (sometimes denoted |A|).
  2. det I = 1, det A = det A>, det AB = det A det B
  3. det A = 0 implies A is singular (non-invertible); otherwise, det A−^1 = 1/ det A
  4. If we multiply one row of A by α to get A′, then det A′^ = α det A. If we swap two rows of A to get A′ then det A′^ = − det A.
  5. In general:

det A = ∑ n

(−1)m+nAmn det A−m,−n (for any m ∈ 1 ,... , N ) (4) = ∑ m

(−1)m+nAmn det A−m,−n (for any n ∈ 1 ,... , N ) (5)

  1. If A = diag(a) then det A = ∏ n an (other special cases exist).

Positive definite matrices

  1. For a quadratic form, x>Ax = ∑ m^ ∑ n Amnxmxn, we can assume A is symmetric.
  2. If A ∈ SN^ , we say A is pd if for all x ∈ RN^ , x>Ax > 0 (we write A  0). Set is SN ++.
  1. Noise 4....

Often will think in terms of a data generating model. Discrete distributions take on discrete values:

  1. Bernoulli (coin flipping): p(1) = π, p(0) = 1 − π for π ∈ [0, 1]. Also p(x) = πx(1 − π)^1 −x.
  2. Binomial (coin flipping, cont’d): what is the probability of k heads in a sequence of n trials (n ≥ k)? p(k | n, π) = (nk^ )πk(1 − π)n−k.
  3. Multinomial (rolling dice): parameter vector θ ∈ RK^ ≥ 0 with ∑ k θk = 1. Let xk be the number of times k comes up in n rolls, then p(x | θ, n) = (^ Q kn xk^ ) ∏ k θ kx k.

Continuous distributions take on continuous values. Think of discrete distributions with number of values approaching infinity, and probability of each approaching zero.

  1. Req: ∫^ −∞∞ dx p(x) = 1.
  2. Events are: p(a < x < b) = ∫^ ab dx p(x)

Examples:

  1. Uniform distribution: p(x | R) = 1 0 ≤x≤R (^) R^1
  2. Univariate normal distribution (x, μ, σ^2 ∈ R)

p(x | μ, σ^2 ) = √ 21 πσ 2 exp

[

− (^21) σ 2 (x − μ)^2

]

Examples...

  1. Multivariate normal distribution (x, μ ∈ RN^ , Σ ∈ SN + ):

p(x | μ, Σ) = √(2π)^1 N (^) det Σ exp

[

− 12 (x − μ)>Σ−^1 (x − μ)

]

Measure distance with Mahalanobis, points of equal distance have constant density. Examples...

Expectations:

  1. For discrete p, Ex∼p[x] = ∑ i p(xi)xi
  2. For continuous p, Ex∼p[x] = ∫^ dx p(x)x
  3. Called the mean, or center of mass; not the same as the mode.
  4. Expectations of functions are obtained by replacing “∑ x” in definition with f (x); eg: Ex∼p[f (x)] = i p(xi)f^ (xi).
  1. If a independent of x, then E[ax] = aE[x].
  2. If x and y are independent then E[x + y] = E[x] + E[y].
  3. Often E[xy] 6 = E[x]E[y]

The variance is a measure of dispersion: V[x] = E [(x − E[x])^2 ]^ = E[x^2 ] − (E[x])^2. Covariance: Cov[x, y] = V[x, y] = E [(x − E[x])(y − E[y])] If p is a joint distribution (p(x, y)), then ∫^ dx ∫^ dy p(x, y) = 1 and can obtain marginal by p(x) = ∫^ dy p(x, y). x and y are independent in p(x, y) if p(x, y) = p(x)p(y). Simplifies marginalization a lot! Conditional: p(y | x) = p(x, y)/p(x) and p(x, y) = p(y | x)p(x) = p(x | y)p(y). If independent, p(y | x) = p(y). Yields chain rule. Bayes’ rule: p(y | x) = p(x^ p|^ (yx))p (y)as prior times likeligood over marginal.