Matrix Cookbook
description
Transcript of Matrix Cookbook
-
The Matrix Cookbook
Kaare Brandt PetersenMichael Syskind Pedersen
Version: October 3, 2005
What is this? These pages are a collection of facts (identities, approxima-tions, inequalities, relations, ...) about matrices and matters relating to them.It is collected in this form for the convenience of anyone who wants a quickdesktop reference .
Disclaimer: The identities, approximations and relations presented here wereobviously not invented but collected, borrowed and copied from a large amountof sources. These sources include similar but shorter notes found on the internetand appendices in books - see the references for a full list.
Errors: Very likely there are errors, typos, and mistakes for which we apolo-gize and would be grateful to receive corrections at [email protected].
Its ongoing: The project of keeping a large repository of relations involvingmatrices is naturally ongoing and the version will be apparent from the date inthe header.
Suggestions: Your suggestion for additional content or elaboration of sometopics is most welcome at [email protected].
Acknowledgements: We would like to thank the following for discussions,proofreading, extensive corrections and suggestions: Esben Hoegh-Rasmussenand Vasile Sima.
Keywords: Matrix algebra, matrix relations, matrix identities, derivative ofdeterminant, derivative of inverse matrix, differentiate a matrix.
1
-
CONTENTS CONTENTS
Contents
1 Basics 51.1 Trace and Determinants . . . . . . . . . . . . . . . . . . . . . . . 51.2 The Special Case 2x2 . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 Derivatives 72.1 Derivatives of a Determinant . . . . . . . . . . . . . . . . . . . . 72.2 Derivatives of an Inverse . . . . . . . . . . . . . . . . . . . . . . . 82.3 Derivatives of Matrices, Vectors and Scalar Forms . . . . . . . . 92.4 Derivatives of Traces . . . . . . . . . . . . . . . . . . . . . . . . . 112.5 Derivatives of Structured Matrices . . . . . . . . . . . . . . . . . 12
3 Inverses 153.1 Basic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.2 Exact Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163.3 Implication on Inverses . . . . . . . . . . . . . . . . . . . . . . . . 173.4 Approximations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.5 Generalized Inverse . . . . . . . . . . . . . . . . . . . . . . . . . . 173.6 Pseudo Inverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4 Complex Matrices 194.1 Complex Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 19
5 Decompositions 225.1 Eigenvalues and Eigenvectors . . . . . . . . . . . . . . . . . . . . 225.2 Singular Value Decomposition . . . . . . . . . . . . . . . . . . . . 225.3 Triangular Decomposition . . . . . . . . . . . . . . . . . . . . . . 23
6 Statistics and Probability 246.1 Definition of Moments . . . . . . . . . . . . . . . . . . . . . . . . 246.2 Expectation of Linear Combinations . . . . . . . . . . . . . . . . 256.3 Weighted Scalar Variable . . . . . . . . . . . . . . . . . . . . . . 26
7 Gaussians 277.1 Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277.2 Moments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297.3 Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317.4 Mixture of Gaussians . . . . . . . . . . . . . . . . . . . . . . . . . 32
8 Special Matrices 338.1 Units, Permutation and Shift . . . . . . . . . . . . . . . . . . . . 338.2 The Singleentry Matrix . . . . . . . . . . . . . . . . . . . . . . . 348.3 Symmetric and Antisymmetric . . . . . . . . . . . . . . . . . . . 368.4 Toeplitz Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . 368.5 Positive Definite and Semi-definite Matrices . . . . . . . . . . . . 388.6 Block matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 2
-
CONTENTS CONTENTS
9 Functions and Operators 419.1 Functions and Series . . . . . . . . . . . . . . . . . . . . . . . . . 419.2 Kronecker and Vec Operator . . . . . . . . . . . . . . . . . . . . 429.3 Solutions to Systems of Equations . . . . . . . . . . . . . . . . . 439.4 Matrix Norms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459.5 Rank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469.6 Integral Involving Dirac Delta Functions . . . . . . . . . . . . . . 469.7 Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
A One-dimensional Results 47A.1 Gaussian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47A.2 One Dimensional Mixture of Gaussians . . . . . . . . . . . . . . . 48
B Proofs and Details 50B.1 Misc Proofs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 3
-
CONTENTS CONTENTS
Notation and Nomenclature
A MatrixAij Matrix indexed for some purposeAi Matrix indexed for some purposeAij Matrix indexed for some purposeAn Matrix indexed for some purpose or
The n.th power of a square matrixA1 The inverse matrix of the matrix AA+ The pseudo inverse matrix of the matrix A (see Sec. 3.6)A1/2 The square root of a matrix (if unique), not elementwise(A)ij The (i, j).th entry of the matrix AAij The (i, j).th entry of the matrix A
[A]ij The ij-submatrix, i.e. A with i.th row and j.th column deleteda Vectorai Vector indexed for some purposeai The i.th element of the vector aa Scalar
-
1 BASICS
1 Basics
(AB)1 = B1A1
(ABC...)1 = ...C1B1A1
(AT )1 = (A1)T
(A + B)T = AT + BT
(AB)T = BT AT
(ABC...)T = ...CT BT AT
(AH)1 = (A1)H
(A + B)H = AH + BH
(AB)H = BHAH
(ABC...)H = ...CHBHAH
1.1 Trace and Determinants
Tr(A) =
iAiiTr(A) =
ii, i = eig(A)
Tr(A) = Tr(AT )Tr(AB) = Tr(BA)
Tr(A + B) = Tr(A) + Tr(B)Tr(ABC) = Tr(BCA) = Tr(CAB)
det(A) =
ii i = eig(A)det(AB) = det(A) det(B)det(A1) = 1/ det(A)
1.2 The Special Case 2x2
Consider the matrix A
A =[
A11 A12A21 A22
]
Determinant and trace
det(A) = A11A22 A12A21Tr(A) = A11 + A22
Eigenvalues2 Tr(A) + det(A) = 0
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 5
-
1.2 The Special Case 2x2 1 BASICS
1 =Tr(A) +
Tr(A)2 4 det(A)
22 =
Tr(A)
Tr(A)2 4 det(A)2
1 + 2 = Tr(A) 12 = det(A)
Eigenvectors
v1 [
A121 A11
]v2
[A12
2 A11
]
Inverse
A1 =1
det(A)
[A22 A12A21 A11
]
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 6
-
2 DERIVATIVES
2 Derivatives
This section is covering differentiation of a number of expressions with respect toa matrix X. Note that it is always assumed that X has no special structure, i.e.that the elements of X are independent (e.g. not symmetric, Toeplitz, positivedefinite). See section 2.5 for differentiation of structured matrices. The basicassumptions can be written in a formula as
XklXij
= iklj
that is for e.g. vector forms,[xy
]
i
=xiy
[x
y
]
i
=x
yi
[xy
]
ij
=xiyj
The following rules are general and very useful when deriving the differential ofan expression ([12]):
A = 0 (A is a constant) (1)(X) = X (2)
(X + Y) = X + Y (3)(Tr(X)) = Tr(X) (4)
(XY) = (X)Y + X(Y) (5)(X Y) = (X) Y + X (Y) (6)(XY) = (X)Y + X (Y) (7)
(X1) = X1(X)X1 (8)(det(X)) = det(X)Tr(X1X) (9)
(ln(det(X))) = Tr(X1X) (10)XT = (X)T (11)XH = (X)H (12)
2.1 Derivatives of a Determinant
2.1.1 General form
det(Y)x
= det(Y)Tr[Y1
Yx
]
2.1.2 Linear forms
det(X)X
= det(X)(X1)T
det(AXB)X
= det(AXB)(X1)T = det(AXB)(XT )1
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 7
AdministratorPencil
-
2.2 Derivatives of an Inverse 2 DERIVATIVES
2.1.3 Square forms
If X is square and invertible, then
det(XT AX)X
= 2 det(XT AX)XT
If X is not square but A is symmetric, then
det(XT AX)X
= 2 det(XT AX)AX(XT AX)1
If X is not square and A is not symmetric, then
det(XT AX)X
= det(XT AX)(AX(XT AX)1 + AT X(XT AT X)1) (13)
2.1.4 Other nonlinear forms
Some special cases are (See [8, 7])
ln det(XT X)|X
= 2(X+)T
ln det(XT X)X+
= 2XT
ln | det(X)|X
= (X1)T = (XT )1
det(Xk)X
= k det(Xk)XT
2.2 Derivatives of an Inverse
From [17] we have the basic identity
Y1
x= Y1 Y
xY1
from which it follows
(X1)klXij
= (X1)ki(X1)jlaT X1b
X= XT abT XT
det(X1)X
= det(X1)(X1)T
Tr(AX1B)X
= (X1BAX1)T
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 8
-
2.3 Derivatives of Matrices, Vectors and Scalar Forms 2 DERIVATIVES
2.3 Derivatives of Matrices, Vectors and Scalar Forms
2.3.1 First Order
xT ax
=aT xx
= a
aT XbX
= abT
aT XT bX
= baT
aT XaX
=aT XT a
X= aaT
XXij
= Jij
(XA)ijXmn
= im(A)nj = (JmnA)ij
(XT A)ijXmn
= in(A)mj = (JnmA)ij
2.3.2 Second Order
Xij
klmn
XklXmn = 2
kl
Xkl
bT XT XcX
= X(bcT + cbT )
(Bx + b)T C(Dx + d)x
= BT C(Dx + d) + DT CT (Bx + b)
(XT BX)klXij
= lj(XT B)ki + kj(BX)il
(XT BX)Xij
= XT BJij + JjiBX (Jij)kl = ikjl
See Sec 8.2 for useful properties of the Single-entry matrix Jij
xT Bxx
= (B + BT )x
bT XT DXcX
= DT XbcT + DXcbT
X(Xb + c)T D(Xb + c) = (D + DT )(Xb + c)bT
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 9
-
2.3 Derivatives of Matrices, Vectors and Scalar Forms 2 DERIVATIVES
Assume W is symmetric, then
s(xAs)T W(xAs) = 2AT W(xAs)
s(x s)T W(x s) = 2W(x s)
x(xAs)T W(xAs) = 2W(xAs)
A(xAs)T W(xAs) = 2W(xAs)sT
2.3.3 Higher order and non-linear
XaT Xnb =
n1r=0
(Xr)T abT (Xn1r)T (14)
XaT (Xn)T Xnb =
n1r=0
[Xn1rabT (Xn)T Xr
+(Xr)T XnabT (Xn1r)T]
(15)
See B.1.1 for a proof.Assume s and r are functions of x, i.e. s = s(x), r = r(x), and that A is aconstant, then
xsT As =
[sx
]T(A + AT )s
xsT Ar =
[sx
]TAs +
[rx
]TAT r
2.3.4 Gradient and Hessian
Using the above we have for the gradient and the hessian
f = xT Ax + bT x
xf = fx
= (A + AT )x + b
2f
xxT= A + AT
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 10
-
2.4 Derivatives of Traces 2 DERIVATIVES
2.4 Derivatives of Traces
2.4.1 First Order
XTr(X) = I
XTr(XA) = AT (16)
XTr(AXB) = AT BT
XTr(AXT B) = BA
XTr(XT A) = A
XTr(AXT ) = A
2.4.2 Second Order
XTr(X2) = 2X
XTr(X2B) = (XB + BX)T
XTr(XT BX) = BX + BT X
XTr(XBXT ) = XBT + XB
XTr(AXBX) = AT XT BT + BT XT AT
XTr(XT X) = 2X
XTr(BXXT ) = (B + BT )X
XTr(BT XT CXB) = CT XBBT + CXBBT
XTr
[XT BXC
]= BXC + BT XCT
XTr(AXBXT C) = AT CT XBT + CAXB
XTr
[(AXb + c)(AXb + c)T
]= 2AT (AXb + c)bT
See [7].
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 11
-
2.5 Derivatives of Structured Matrices 2 DERIVATIVES
2.4.3 Higher Order
XTr(Xk) = k(Xk1)T
XTr(AXk) =
k1r=0
(XrAXkr1)T
XTr
[BT XT CXXT CXB
]= CXXT CXBBT
+CT XBBT XT CT X+CXBBT XT CX+CT XXT CT XBBT
2.4.4 Other
XTr(AX1B) = (X1BAX1)T = XT AT BT XT
Assume B and C to be symmetric, then
XTr
[(XT CX)1A
]= (CX(XT CX)1)(A + AT )(XT CX)1
XTr
[(XT CX)1(XT BX)
]= 2CX(XT CX)1XT BX(XT CX)1
+2BX(XT CX)1
See [7].
2.5 Derivatives of Structured Matrices
Assume that the matrix A has some structure, i.e. symmetric, toeplitz, etc.In that case the derivatives of the previous section does not apply in general.Instead, consider the following general rule for differentiating a scalar functionf(A)
df
dAij=
kl
f
Akl
AklAij
= Tr
[[f
A
]TAAij
]
The matrix differentiated with respect to itself is in this document referred toas the structure matrix of A and is defined simply by
AAij
= Sij
If A has no special structure we have simply Sij = Jij , that is, the structurematrix is simply the singleentry matrix. Many structures have a representationin singleentry matrices, see Sec. 8.2.6 for more examples of structure matrices.
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 12
-
2.5 Derivatives of Structured Matrices 2 DERIVATIVES
2.5.1 The Chain Rule
Sometimes the objective is to find the derivative of a matrix which is a functionof another matrix. Let U = f(X), the goal is to find the derivative of thefunction g(U) with respect to X:
g(U)X
=g(f(X))
X(17)
Then the Chain Rule can then be written the following way:
g(U)X
=g(U)xij
=M
k=1
N
l=1
g(U)ukl
uklxij
(18)
Using matrix notation, this can be written as:
g(U)Xij
= Tr[(g(U)U
)TUXij
]. (19)
2.5.2 Symmetric
If A is symmetric, then Sij = Jij + Jji JijJij and therefore
df
dA=
[f
A
]+
[f
A
]T diag
[f
A
]
That is, e.g., ([5], [18]):
Tr(AX)X
= A + AT (A I), see (23) (20) det(X)
X= det(X)(2X1 (X1 I)) (21)
ln det(X)X
= 2X1 (X1 I) (22)
2.5.3 Diagonal
If X is diagonal, then ([12]):
Tr(AX)X
= A I (23)
2.5.4 Toeplitz
Like symmetric matrices and diagonal matrices also Toeplitz matrices has aspecial structure which should be taken into account when the derivative withrespect to a matrix with Toeplitz structure.
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 13
-
2.5 Derivatives of Structured Matrices 2 DERIVATIVES
Tr(AT)T
(24)
=Tr(TA)
T
=
Tr(A) Tr([AT ]n1) Tr([[AT ]1n]n1,2) An1
Tr([AT ]1n)) Tr(A). . .
. . ....
Tr([[AT ]1n]2,n1). . .
. . .. . . Tr([[AT ]1n]n1,2)
.
.
.. . .
. . .. . . Tr([AT ]n1)
A1n Tr([[AT ]1n]2,n1) Tr([AT ]1n)) Tr(A)
(A)
As it can be seen, the derivative (A) also has a Toeplitz structure. Each valuein the diagonal is the sum of all the diagonal valued in A, the values in thediagonals next to the main diagonal equal the sum of the diagonal next to themain diagonal in AT . This result is only valid for the unconstrained Toeplitzmatrix. If the Toeplitz matrix also is symmetric, the same derivative yields
Tr(AT)T
=Tr(TA)
T= (A) + (A)T (A) I (25)
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 14
-
3 INVERSES
3 Inverses
3.1 Basic
3.1.1 Definition
The inverse A1 of a matrix A Cnn is defined such thatAA1 = A1A = I, (26)
where I is the nn identity matrix. If A1 exists, A is said to be nonsingular.Otherwise, A is said to be singular (see e.g. [9]).
3.1.2 Cofactors and Adjoint
The submatrix of a matrix A, denoted by [A]ij is a (n 1) (n 1) matrixobtained by deleting the ith row and the jth column of A. The (i, j) cofactorof a matrix is defined as
cof(A, i, j) = (1)i+j det([A]ij), (27)The matrix of cofactors can be created from the cofactors
cof(A) =
cof(A, 1, 1) cof(A, 1, n)
... cof(A, i, j)...
cof(A, n, 1) cof(A, n, n)
(28)
The adjoint matrix is the transpose of the cofactor matrix
adj(A) = (cof(A))T , (29)
3.1.3 Determinant
The determinant of a matrix A Cnn is defined as (see [9])
det(A) =n
j=1
(1)j+1A1j det ([A]1j)
=n
j=1
A1jcof(A, 1, j). (30)
3.1.4 Construction
The inverse matrix can be constructed, using the adjoint matrix, by
A1 =1
det(A) adj(A) (31)
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 15
-
3.2 Exact Relations 3 INVERSES
3.1.5 Condition number
The condition number of a matrix c(A) is the ratio between the largest and thesmallest singular value of a matrix (see Section 5.2 on singular values),
c(A) =d+d
The condition number can be used to measure how singular a matrix is. If thecondition number is large, it indicates that the matrix is nearly singular. Thecondition number can also be estimated from the matrix norms. Here
c(A) = A A1, (32)
where is a norm such as e.g the 1-norm, the 2-norm, the -norm or theFrobenius norm (see Sec 9.4 for more on matrix norms).
3.2 Exact Relations
3.2.1 The Woodbury identity
(A + CBCT )1 = A1 A1C(B1 + CT A1C)1CT A1
If P,R are positive definite, then (see [19])
(P1 + BT R1B)1BT R1 = PBT (BPBT + R)1
3.2.2 The Kailath Variant
(A + BC)1 = A1 A1B(I + CA1B)1CA1
See [4] page 153.
3.2.3 The Searle Set of Identities
The following set of identities, can be found in [15], page 151,
(I + A1)1 = A(A + I)1
(A + BBT )1B = A1B(I + BT A1B)1
(A1 + B1)1 = A(A + B)1B = B(A + B)1A
AA(A + B)1A = BB(A + B)1BA1 + B1 = A1(A + B)B1
(I + AB)1 = IA(I + BA)1B(I + AB)1A = A(I + BA)1
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 16
-
3.3 Implication on Inverses 3 INVERSES
3.3 Implication on Inverses
(A + B)1 = A1 + B1 AB1A = BA1BSee [15].
3.3.1 A PosDef identity
Assume P,R to be positive definite and invertible, then
(P1 + BT R1B)1BT R1 = PBT (BPBT + R)1
See [19].
3.4 Approximations
(I + A)1 = IA + A2 A3 + ...AA(I + A)1A = IA1 if A large and symmetric
If 2 is small then
(Q + 2M)1 = Q1 2Q1MQ1
3.5 Generalized Inverse
3.5.1 Definition
A generalized inverse matrix of the matrix A is any matrix A such that (see[16])
AAA = A
The matrix A is not unique.
3.6 Pseudo Inverse
3.6.1 Definition
The pseudo inverse (or Moore-Penrose inverse) of a matrix A is the matrix A+
that fulfils
I AA+A = AII A+AA+ = A+
III AA+ symmetricIV A+A symmetric
The matrix A+ is unique and does always exist.
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 17
-
3.6 Pseudo Inverse 3 INVERSES
3.6.2 Properties
Assume A+ to be the pseudo-inverse of A, then (See [3])
(A+)+ = A(AT )+ = (A+)T
(cA)+ = (1/c)A+
(AT A)+ = A+(AT )+
(AAT )+ = (AT )+A+
Assume A to have full rank, then
(AA+)(AA+) = AA+
(A+A)(A+A) = A+ATr(AA+) = rank(AA+) (See [16])Tr(A+A) = rank(A+A) (See [16])
3.6.3 Construction
Assume that A has full rank, then
A n n Square rank(A) = n A+ = A1A nm Broad rank(A) = n A+ = AT (AAT )1A nm Tall rank(A) = m A+ = (AT A)1AT
Assume A does not have full rank, i.e. A is nm and rank(A) = r < min(n,m).The pseudo inverse A+ can be constructed from the singular value decomposi-tion A = UDVT , by
A+ = VD+UT
A different way is this: There does always exists two matrices C n r and Dr m of rank r, such that A = CD. Using these matrices it holds that
A+ = DT (DDT )1(CT C)1CT
See [3].
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 18
-
4 COMPLEX MATRICES
4 Complex Matrices
4.1 Complex Derivatives
In order to differentiate an expression f(z) with respect to a complex z, theCauchy-Riemann equations have to be satisfied ([7]):
df(z)dz
=
-
4.1 Complex Derivatives 4 COMPLEX MATRICES
Complex Gradient Matrix: If f is a real function of a complex matrix Z,then the complex gradient matrix is given by ([2])
f(Z) = 2df(Z)dZ
(40)
=f(Z)
-
4.1 Complex Derivatives 4 COMPLEX MATRICES
complex number.
Tr(AXH)
-
5 DECOMPOSITIONS
5 Decompositions
5.1 Eigenvalues and Eigenvectors
5.1.1 Definition
The eigenvectors v and eigenvalues are the ones satisfying
Avi = ivi
AV = VD, (D)ij = ijiwhere the columns of V are the vectors vi
5.1.2 General Properties
eig(AB) = eig(BA)A is nm At most min(n,m) distinct i
rank(A) = r At most r non-zero i
5.1.3 Symmetric
Assume A is symmetric, then
VVT = I (i.e. V is orthogonal)i R (i.e. i is real)
Tr(Ap) =
ipi
eig(I + cA) = 1 + cieig(A1) = 1i
5.2 Singular Value Decomposition
Any nm matrix A can be written asA = UDVT
whereU = eigenvectors of AAT n nD =
diag(eig(AAT )) nm
V = eigenvectors of AT A mm
5.2.1 Symmetric Square decomposed into squares
Assume A to be n n and symmetric. Then[
A]
=[
V] [
D] [
VT]
where D is diagonal with the eigenvalues of A and V is orthogonal and theeigenvectors of A.
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 22
-
5.3 Triangular Decomposition 5 DECOMPOSITIONS
5.2.2 Square decomposed into squares
Assume A Rnn. Then[
A]
=[
V] [
D] [
UT]
where D is diagonal with the square root of the eigenvalues of AAT , V is theeigenvectors of AAT and UT is the eigenvectors of AT A.
5.2.3 Square decomposed into rectangular
Assume VDUT = 0 then we can expand the SVD of A into[
A]
=[
V V] [ D 0
0 D
] [UT
UT
]
where the SVD of A is A = VDUT .
5.2.4 Rectangular decomposition I
Assume A is nm[
A]
=[
V] [
D] [
UT]
where D is diagonal with the square root of the eigenvalues of AAT , V is theeigenvectors of AAT and UT is the eigenvectors of AT A.
5.2.5 Rectangular decomposition II
Assume A is nm[
A]
=[
V] D
UT
5.2.6 Rectangular decomposition III
Assume A is nm[
A]
=[
V] [
D] UT
where D is diagonal with the square root of the eigenvalues of AAT , V is theeigenvectors of AAT and UT is the eigenvectors of AT A.
5.3 Triangular Decomposition
5.3.1 Cholesky-decomposition
Assume A is positive definite, then
A = BT B
where B is a unique upper triangular matrix.
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 23
-
6 STATISTICS AND PROBABILITY
6 Statistics and Probability
6.1 Definition of Moments
Assume x Rn1 is a random variable
6.1.1 Mean
The vector of means, m, is defined by
(m)i = xi
6.1.2 Covariance
The matrix of covariance M is defined by
(M)ij = (xi xi)(xj xj)
or alternatively asM = (xm)(xm)T
6.1.3 Third moments
The matrix of third centralized moments in some contexts referred to ascoskewness is defined using the notation
m(3)ijk = (xi xi)(xj xj)(xk xk)
asM3 =
[m
(3)::1 m
(3)::2 ...m
(3)::n
]
where : denotes all elements within the given index. M3 can alternatively beexpressed as
M3 = (xm)(xm)T (xm)T
6.1.4 Fourth moments
The matrix of fourth centralized moments in some contexts referred to ascokurtosis is defined using the notation
m(4)ijkl = (xi xi)(xj xj)(xk xk)(xl xl)
asM4 =
[m
(4)::11m
(4)::21...m
(4)::n1|m(4)::12m(4)::22...m(4)::n2|...|m(4)::1nm(4)::2n...m(4)::nn
]
or alternatively as
M4 = (xm)(xm)T (xm)T (xm)T
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 24
-
6.2 Expectation of Linear Combinations6 STATISTICS AND PROBABILITY
6.2 Expectation of Linear Combinations
6.2.1 Linear Forms
Assume X and x to be a matrix and a vector of random variables. Then (seeSee [16])
E[AXB + C] = AE[X]B + C
Var[Ax] = AVar[x]AT
Cov[Ax,By] = ACov[x,y]BT
Assume x to be a stochastic vector with mean m, then (see [7])
E[Ax + b] = Am + bE[Ax] = Am
E[x + b] = m + b
6.2.2 Quadratic Forms
Assume A is symmetric, c = E[x] and = Var[x]. Assume also that allcoordinates xi are independent, have the same central moments 1, 2, 3, 4and denote a = diag(A). Then (See [16])
E[xT Ax] = Tr(A) + cT Ac
Var[xT Ax] = 222Tr(A2) + 42cT A2c + 43cT Aa + (4 322)aT a
Also, assume x to be a stochastic vector with mean m, and covariance M. Then(see [7])
E[(Ax + a)(Bx + b)T ] = AMBT + (Am + a)(Bm + b)T
E[xxT ] = M + mmT
E[xaT x] = (M + mmT )aE[xT axT ] = aT (M + mmT )
E[(Ax)(Ax)T ] = A(M + mmT )AT
E[(x + a)(x + a)T ] = M + (m + a)(m + a)T
E[(Ax + a)T (Bx + b)] = Tr(AMBT ) + (Am + a)T (Bm + b)E[xT x] = Tr(M) + mT m
E[xT Ax] = Tr(AM) + mT AmE[(Ax)T (Ax)] = Tr(AMAT ) + (Am)T (Am)
E[(x + a)T (x + a)] = Tr(M) + (m + a)T (m + a)
See [7].
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 25
-
6.3 Weighted Scalar Variable 6 STATISTICS AND PROBABILITY
6.2.3 Cubic Forms
Assume x to be a stochastic vector with independent coordinates, mean m,covariance M and central moments v3 = E[(xm)3]. Then (see [7])
E[(Ax + a)(Bx + b)T (Cx + c)] = Adiag(BT C)v3+Tr(BMCT )(Am + a)+AMCT (Bm + b)+(AMBT + (Am + a)(Bm + b)T )(Cm + c)
E[xxT x] = v3 + 2Mm + (Tr(M) + mT m)mE[(Ax + a)(Ax + a)T (Ax + a)] = Adiag(AT A)v3
+[2AMAT + (Ax + a)(Ax + a)T ](Am + a)+Tr(AMAT )(Am + a)
E[(Ax + a)bT (Cx + c)(Dx + d)T ] = (Ax + a)bT (CMDT + (Cm + c)(Dm + d)T )+(AMCT + (Am + a)(Cm + c)T )b(Dm + d)T
+bT (Cm + c)(AMDT (Am + a)(Dm + d)T )
6.3 Weighted Scalar Variable
Assume x Rn1 is a random variable, w Rn1 is a vector of constants andy is the linear combination y = wT x. Assume further that m,M2,M3,M4denotes the mean, covariance, and central third and fourth moment matrix ofthe variable x. Then it holds that
y = wT m(y y)2 = wT M2w(y y)3 = wT M3w w(y y)4 = wT M4w w w
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 26
-
7 GAUSSIANS
7 Gaussians
7.1 Basics
7.1.1 Density and normalization
The density of x N (m,) is
p(x) =1
det(2)exp
[1
2(xm)T 1(xm)
]
Note that if x is d-dimensional, then det(2) = (2)d det().Integration and normalization
exp
[1
2(xm)T 1(xm)
]dx =
det(2)
exp
[1
2xT Ax + bT x
]dx =
det(2A1) exp
[12bT A1b
]
exp
[1
2Tr(ST AS) + Tr(BT S)
]dS =
det(2A1) exp
[12Tr(BT A1B)
]
The derivatives of the density are
p(x)x
= p(x)1(xm)
2p
xxT= p(x)
(1(xm)(xm)T 1 1
)
7.1.2 Marginal Distribution
Assume x Nx(,) where
x =[
xaxb
] =
[ab
] =
[a cTc b
]
then
p(xa) = Nxa(a,a)p(xb) = Nxb(b,b)
7.1.3 Conditional Distribution
Assume x Nx(,) where
x =[
xaxb
] =
[ab
] =
[a cTc b
]
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 27
-
7.1 Basics 7 GAUSSIANS
then
p(xa|xb) = Nxa(a, a){ a = a + c1b (xb b)
a = a + c1b Tc
p(xb|xa) = Nxb(b, b){ b = b + Tc 1a (xa a)
b = b + Tc 1a c
7.1.4 Linear combination
Assume x N (mx,x) and y N (my,y) then
Ax + By + c N (Amx + Bmy + c,AxAT + ByBT )
7.1.5 Rearranging Means
NAx[m,] =
det(2(AT 1A)1)det(2)
Nx[A1m, (AT 1A)1]
7.1.6 Rearranging into squared form
If A is symmetric, then
12xT Ax + bT x = 1
2(xA1b)T A(xA1b) + 1
2bT A1b
12Tr(XT AX)+Tr(BT X) = 1
2Tr[(XA1B)T A(XA1B)]+1
2Tr(BT A1B)
7.1.7 Sum of two squared forms
In vector formulation (assuming 1,2 are symmetric)
12(xm1)T 11 (xm1)
12(xm2)T 12 (xm2)
= 12(xmc)T 1c (xmc) + C
1c = 11 +
12
mc = (11 + 12 )
1(11 m1 + 12 m2)
C =12(mT1
11 + m
T2
12 )(
11 +
12 )
1(11 m1 + 12 m2)
12
(mT1
11 m1 + m
T2
12 m2
)
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 28
-
7.2 Moments 7 GAUSSIANS
In a trace formulation (assuming 1,2 are symmetric)
12Tr((XM1)T 11 (XM1))
12Tr((XM2)T 12 (XM2))
= 12Tr[(XMc)T 1c (XMc)] + C
1c = 11 +
12
Mc = (11 + 12 )
1(11 M1 + 12 M2)
C =12Tr
[(11 M1 +
12 M2)
T (11 + 12 )
1(11 M1 + 12 M2)
]
12Tr(MT1
11 M1 + M
T2
12 M2)
7.1.8 Product of gaussian densities
Let Nx(m,) denote a density of x, thenNx(m1,1) Nx(m2,2) = ccNx(mc,c)
cc = Nm1(m2, (1 + 2))=
1det(2(1 + 2))
exp[1
2(m1 m2)T (1 + 2)1(m1 m2)
]
mc = (11 + 12 )
1(11 m1 + 12 m2)
c = (11 + 12 )
1
but note that the product is not normalized as a density of x.
7.2 Moments
7.2.1 Mean and covariance of linear forms
First and second moments. Assume x N (m,)E(x) = m
Cov(x,x) = Var(x) = = E(xxT ) E(x)E(xT ) = E(xxT )mmT
As for any other distribution is holds for gaussians that
E[Ax] = AE[x]
Var[Ax] = AVar[x]AT
Cov[Ax,By] = ACov[x,y]BT
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 29
-
7.2 Moments 7 GAUSSIANS
7.2.2 Mean and variance of square forms
Mean and variance of square forms: Assume x N (m,)
E(xxT ) = + mmT
E[xT Ax] = Tr(A) + mT AmVar(xT Ax) = 24Tr(A2) + 42mT A2m
E[(xm)T A(xm)] = (mm)T A(mm) + Tr(A)
Assume x N (0, 2I) and A and B to be symmetric, then
Cov(xT Ax,xT Bx) = 24Tr(AB)
7.2.3 Cubic forms
E[xbT xxT ] = mbT (M + mmT ) + (M + mmT )bmT
+bT m(MmmT )
7.2.4 Mean of Quartic Forms
E[xxT xxT ] = 2( + mmT )2 + mT m(mmT )+Tr()( + mmT )
E[xxT AxxT ] = ( + mmT )(A + AT )( + mmT )+mT Am(mmT ) + Tr[A( + mmT )]
E[xT xxT x] = 2Tr(2) + 4mT m + (Tr() + mT m)2
E[xT AxxT Bx] = Tr[A(B + BT )] + mT (A + AT )(B + BT )m+(Tr(A) + mT Am)(Tr(B) + mT Bm)
E[aT xbT xcT xdT x]= (aT ( + mmT )b)(cT ( + mmT )d)
+(aT ( + mmT )c)(bT ( + mmT )d)+(aT ( + mmT )d)(bT ( + mmT )c) 2aT mbT mcT mdT m
E[(Ax + a)(Bx + b)T (Cx + c)(Dx + d)T ]= [ABT + (Am + a)(Bm + b)T ][CDT + (Cm + c)(Dm + d)T ]
+[ACT + (Am + a)(Cm + c)T ][BDT + (Bm + b)(Dm + d)T ]+(Bm + b)T (Cm + c)[ADT (Am + a)(Dm + d)T ]+Tr(BCT )[ADT + (Am + a)(Dm + d)T ]
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 30
-
7.3 Miscellaneous 7 GAUSSIANS
E[(Ax + a)T (Bx + b)(Cx + c)T (Dx + d)]= Tr[A(CT D + DT C)BT ]
+[(Am + a)T B + (Bm + b)T A][CT (Dm + d) + DT (Cm + c)]+[Tr(ABT ) + (Am + a)T (Bm + b)][Tr(CDT ) + (Cm + c)T (Dm + d)]
See [7].
7.2.5 Moments
E[x] =
k
kmk
Cov(x) =
k
kkk(k + mkmTk mkmTk)
7.3 Miscellaneous
7.3.1 Whitening
Assume x N (m,) then
z = 1/2(xm) N (0, I)
Conversely having z N (0, I) one can generate data x N (m,) by setting
x = 1/2z + m N (m,)
Note that 1/2 means the matrix which fulfils 1/21/2 = , and that it existsand is unique since is positive definite.
7.3.2 The Chi-Square connection
Assume x N (m,) and x to be n dimensional, then
z = (xm)T 1(xm) 2n
7.3.3 Entropy
Entropy of a D-dimensional gaussian
H(x) =N (m,) lnN (m,)dx = ln
det(2) D
2
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 31
-
7.4 Mixture of Gaussians 7 GAUSSIANS
7.4 Mixture of Gaussians
7.4.1 Density
The variable x is distributed as a mixture of gaussians if it has the density
p(x) =K
k=1
k1
det(2k)exp
[1
2(xmk)T 1k (xmk)
]
where k sum to 1 and the k all are positive definite.
7.4.2 Derivatives
Defining p(s) =
k kNs(k,k) one get
ln p(s)j
=jNs(j ,j)k kNs(k,k)
jln[jNs(j ,j)]
=jNs(j ,j)k kNs(k,k)
1j
ln p(s)j
=jNs(j ,j)k kNs(k,k)
jln[jNs(j ,j)]
=jNs(j ,j)k kNs(k,k)
[1k (s k)]
ln p(s)j
=jNs(j ,j)k kNs(k,k)
jln[jNs(j ,j)]
=jNs(j ,j)k kNs(k,k)
12
[Tj +
Tj (s j)(s j)T Tj
]
But k and k needs to be constrained.
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 32
-
8 SPECIAL MATRICES
8 Special Matrices
8.1 Units, Permutation and Shift
8.1.1 Unit vector
Let ei Rn1 be the ith unit vector, i.e. the vector which is zero in all entriesexcept the ith at which it is 1.
8.1.2 Rows and Columns
i.th row of A = eTi Aj.th column of A = Aej
8.1.3 Permutations
Let P be some permutation matrix, e.g.
P =
0 1 01 0 00 0 1
= [ e2 e1 e3
]=
eT2eT1eT3
then
AP =[
Ae2 Ae1 Ae2]
PA =
eT2 AeT1 AeT3 A
That is, the first is a matrix which has columns of A but in permuted sequenceand the second is a matrix which has the rows of A but in the permuted se-quence.
8.1.4 Translation, Shift or Lag Operators
Let L denote the lag (or translation or shift) operator defined on a 4 4example by
L =
0 0 0 01 0 0 00 1 0 00 0 1 0
i.e. a matrix of zeros with one on the sub-diagonal, (L)ij = i,j+1. With somesignal xt for t = 1, ..., N , the n.th power of the lag operator shifts the indices,i.e.
(Lnx)t ={ 0 for t = 1, .., n
xtn for t = n + 1, ..., N
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 33
-
8.2 The Singleentry Matrix 8 SPECIAL MATRICES
A related but slightly different matrix is the recurrent shifted operator definedon a 4x4 example by
L =
0 0 0 11 0 0 00 1 0 00 0 1 0
i.e. a matrix defined by (L)ij = i,j+1 + i,1j,dim(L). On a signal x it has theeffect
(Lnx)t = xt , t = [(t n) mod N ] + 1That is, L is like the shift operator L except that it wraps the signal as if itwas periodic and shifted (substituting the zeros with the rear end of the signal).Note that L is invertible and orthogonal, i.e.
L1 = LT
8.2 The Singleentry Matrix
8.2.1 Definition
The single-entry matrix Jij Rnn is defined as the matrix which is zeroeverywhere except in the entry (i, j) in which it is 1. In a 4 4 example onemight have
J23 =
0 0 0 00 0 1 00 0 0 00 0 0 0
The single-entry matrix is very useful when working with derivatives of expres-sions involving matrices.
8.2.2 Swap and Zeros
Assume A to be nm and Jij to be m p
AJij =[
0 0 . . . Ai . . . 0]
i.e. an n p matrix of zeros with the i.th column of A in place of the j.thcolumn. Assume A to be nm and Jij to be p n
JijA =
0...0Aj0...0
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 34
-
8.2 The Singleentry Matrix 8 SPECIAL MATRICES
i.e. an p m matrix of zeros with the j.th row of A in the placed of the i.throw.
8.2.3 Rewriting product of elements
AkiBjl = (AeieTj B)kl = (AJijB)kl
AikBlj = (AT eieTj BT )kl = (AT JijBT )kl
AikBjl = (AT eieTj B)kl = (AT JijB)kl
AkiBlj = (AeieTj BT )kl = (AJijBT )kl
8.2.4 Properties of the Singleentry Matrix
If i = jJijJij = Jij (Jij)T (Jij)T = Jij
Jij(Jij)T = Jij (Jij)T Jij = Jij
If i 6= jJijJij = 0 (Jij)T (Jij)T = 0
Jij(Jij)T = Jii (Jij)T Jij = Jjj
8.2.5 The Singleentry Matrix in Scalar Expressions
Assume A is nm and J is m n, then
Tr(AJij) = Tr(JijA) = (AT )ij
Assume A is n n, J is nm and B is m n, then
Tr(AJijB) = (AT BT )ij
Tr(AJjiB) = (BA)ij
Tr(AJijJijB) = diag(AT BT )ij
Assume A is n n, Jij is nm B is m n, then
xT AJijBx = (AT xxT BT )ij
xT AJijJijBx = diag(AT xxT BT )ij
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 35
-
8.3 Symmetric and Antisymmetric 8 SPECIAL MATRICES
8.2.6 Structure Matrices
The structure matrix is defined by
AAij
= Sij
If A has no special structure then
Sij = Jij
If A is symmetric thenSij = Jij + Jji JijJij
8.3 Symmetric and Antisymmetric
8.3.1 Symmetric
The matrix A is said to be symmetric if
A = AT
Symmetric matrices have many important properties, e.g. that their eigenvaluesare real and eigenvalues orthogonal.
8.3.2 Antisymmetric
The antisymmetric matrix is also known as the skew symmetric matrix. It hasthe following property from which it is defined
A = AT
Hereby, it can be seen that the antisymmetric matrices always have a zerodiagonal. The n n antisymmetric matrices also have the following properties.
det(AT ) = det(A) = (1)n det(A) det(A) = det(A) = 0, if n is odd
8.4 Toeplitz Matrices
A Toeplitz matrix T is a matrix where the elements of each diagonal is thesame. In the n n square case, it has the following structure:
T =
t11 t12 t1nt21
. . . . . ....
.... . . . . . t12
tn1 t21 t11
=
t0 t1 tn1t1
. . . . . ....
.... . . . . . t1
t(n1) t1 t0
(58)
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 36
-
8.4 Toeplitz Matrices 8 SPECIAL MATRICES
A Toeplitz matrix is persymmetric. If a matrix is persymmetric (or orthosym-metric), it means that the matrix is symmetric about its northeast-southwestdiagonal (anti-diagonal) [9]. Persymmetric matrices is a larger class of matrices,since a persymmetric matrix not necessarily has a Toeplitz structure. There aresome special cases of Toeplitz matrices. The symmetric Toeplitz matrix is givenby:
T =
t0 t1 tn1t1
. . . . . ....
.... . . . . . t1
t(n1) t1 t0
(59)
The circular Toeplitz matrix:
TC =
t0 t1 tn1tn
. . . . . ....
.... . . . . . t1
t1 tn1 t0
(60)
The upper triangular Toeplitz matrix:
TU =
t0 t1 tn10
. . . . . ....
.... . . . . . t1
0 0 t0
, (61)
and the lower triangular Toeplitz matrix:
TL =
t0 0 0t1
. . . . . ....
.... . . . . . 0
t(n1) t1 t0
(62)
8.4.1 Properties of Toeplitz Matrices
The Toeplitz matrix has some computational advantages. The addition of twoToeplitz matrices can be done with O(n) flops, multiplication of two Toeplitzmatrices can be done in O(n ln n) flops. Toeplitz equation systems can besolved in O(n2) flops. The inverse of a positive definite Toeplitz matrix canbe found in O(n2) flops too. The inverse of a Toeplitz matrix is persymmetric.The product of two lower triangular Toeplitz matrices is a Toeplitz matrix.The following important relation between the circulant matrix and the discreteFourier transform (DFT) exists
TC = F1n (I (Fnt))Fn, (63)
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 37
-
8.5 Positive Definite and Semi-definite Matrices 8 SPECIAL MATRICES
where t = [t0, t1, , tn1]T is the first row of TC . Fn is the n n discreteFourier transform (DFT) matrix defined as
Fn = DFT(I). (64)
Likewise, F1n is the inverse DFT matrix defined as
F1n = IDFT(I) = (DFT(I))1. (65)
More information on Toeplitz matrices and circulant matrices can be found in[10, 7].
8.5 Positive Definite and Semi-definite Matrices
8.5.1 Definitions
A matrix A is positive definite if and only if
xT Ax > 0, x
A matrix A is positive semi-definite if and only if
xT Ax 0, x
Note that if A is positive definite, then A is also positive semi-definite.
8.5.2 Eigenvalues
The following holds with respect to the eigenvalues:
A pos. def. eig(A) > 0A pos. semi-def. eig(A) 0
8.5.3 Trace
The following holds with respect to the trace:
A pos. def. Tr(A) > 0A pos. semi-def. Tr(A) 0
8.5.4 Inverse
If A is positive definite, then A is invertible and A1 is also positive definite.
8.5.5 Diagonal
If A is positive definite, then Aii > 0,i
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 38
-
8.6 Block matrices 8 SPECIAL MATRICES
8.5.6 Decomposition I
The matrix A is positive semi-definite of rank r there exists a matrix B ofrank r such that A = BBT
The matrix A is positive definite there exists an invertible matrix B suchthat A = BBT
8.5.7 Decomposition II
Assume A is an n n positive semi-definite, then there exists an n r matrixB of rank r such that BT AB = I.
8.5.8 Equation with zeros
Assume A is positive semi-definite, then XT AX = 0 AX = 0
8.5.9 Rank of product
Assume A is positive definite, then rank(BABT ) = rank(B)
8.5.10 Positive definite property
If A is n n positive definite and B is r n of rank r, then BABT is positivedefinite.
8.5.11 Outer Product
If X is n r of rank r, then XXT is positive definite.
8.5.12 Small pertubations
If A is positive definite and B is symmetric, then A tB is positive definite forsufficiently small t.
8.6 Block matrices
Let Aij denote the ijth block of A.
8.6.1 Multiplication
Assuming the dimensions of the blocks matches we have[
A11 A12A21 A22
] [B11 B12B21 B22
]=
[A11B11 + A12B21 A11B12 + A12B22A21B11 + A22B21 A21B12 + A22B22
]
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 39
-
8.6 Block matrices 8 SPECIAL MATRICES
8.6.2 The Determinant
The determinant can be expressed as by the use of
C1 = A11 A12A122 A21C2 = A22 A21A111 A12
as
det([
A11 A12A21 A22
])= det(A22) det(C1) = det(A11) det(C2)
8.6.3 The Inverse
The inverse can be expressed as by the use of
C1 = A11 A12A122 A21C2 = A22 A21A111 A12
as [A11 A12A21 A22
]1=
[C11 A111 A12C12
C12 A21A111 C12
]
=[
A111 + A111 A12C
12 A21A
111 C11 A12A122
A122 A21C11 A122 + A122 A21C11 A12A122
]
8.6.4 Block diagonal
For block diagonal matrices we have
[A11 00 A22
]1=
[(A11)1 0
0 (A22)1
]
det([
A11 00 A22
])= det(A11) det(A22)
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 40
-
9 FUNCTIONS AND OPERATORS
9 Functions and Operators
9.1 Functions and Series
9.1.1 Finite Series
(Xn I)(X I)1 = I + X + X2 + ... + Xn1
9.1.2 Taylor Expansion of Scalar Function
Consider some scalar function f(x) which takes the vector x as an argument.This we can Taylor expand around x0
f(x) = f(x0) + g(x0)T (x x0) + 12(x x0)T H(x0)(x x0)
where
g(x0) =f(x)
x
x0
H(x0) =2f(x)xxT
x0
9.1.3 Matrix Functions by Infinite Series
As for analytical functions in one dimension, one can define a matrix functionfor square matrices X by an infinite series
f(X) =
n=0
cnXn
assuming the limit exists and is finite. If the coefficients cn fulfils
n cnxn < ,
then one can prove that the above series exists and is finite, see [1]. Thus forany analytical function f(x) there exists a corresponding matrix function f(x)constructed by the Taylor expansion. Using this one can prove the followingresults:1) A matrix A is a zero of its own characteristic polynomium [1]:
p() = det(IA) =
n
cnn p(A) = 0
2) If A is square it holds that [1]
A = UBU1 f(A) = Uf(B)U1
3) A useful fact when using power series is that
An 0 for n if |A| < 1
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 41
-
9.2 Kronecker and Vec Operator 9 FUNCTIONS AND OPERATORS
9.1.4 Exponential Matrix Function
In analogy to the ordinary scalar exponential function, one can define exponen-tial and logarithmic matrix functions:
eA
n=0
1n!
An = I + A +12A2 + ...
eA
n=0
1n!
(1)nAn = IA + 12A2 ...
etA
n=0
1n!
(tA)n = I + tA +12t2A2 + ...
ln(I + A)
n=1
(1)n1n
An = A 12A2 +
13A3 ...
Some of the properties of the exponential function are [1]
eAeB = eA+B if AB = BA
(eA)1 = eA
d
dtetA = AetA, t R
9.1.5 Trigonometric Functions
sin(A)
n=0
(1)nA2n+1(2n + 1)!
= A 13!
A3 +15!
A5 ...
cos(A)
n=0
(1)nA2n(2n)!
= I 12!
A2 +14!
A4 ...
9.2 Kronecker and Vec Operator
9.2.1 The Kronecker Product
The Kronecker product of an m n matrix A and an r q matrix B, is anmr nq matrix, AB defined as
AB =
A11B A12B ... A1nBA21B A22B ... A2nB
......
Am1B Am2B ... AmnB
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 42
-
9.3 Solutions to Systems of Equations 9 FUNCTIONS AND OPERATORS
The Kronecker product has the following properties (see [12])
A (B + C) = AB + ACAB 6= BA
A (BC) = (AB)C(AA BB) = AB(AB)
(AB)T = AT BT(AB)(CD) = ABCD
(AB)1 = A1 B1rank(AB) = rank(A)rank(B)
Tr(AB) = Tr(A)Tr(B)det(AB) = det(A)rank(B) det(B)rank(A)
9.2.2 The Vec Operator
The vec-operator applied on a matrix A stacks the columns into a vector, i.e.for a 2 2 matrix
A =[
A11 A12A21 A22
]vec(A) =
A11A21A12A22
Properties of the vec-operator include (see [12])
vec(AXB) = (BT A)vec(X)Tr(AT B) = vec(A)T vec(B)
vec(A + B) = vec(A) + vec(B)vec(A) = vec(A)
9.3 Solutions to Systems of Equations
9.3.1 Existence in Linear Systems
Assume A is nm and consider the linear system
Ax = b
Construct the augmented matrix B = [A b] then
Condition Solutionrank(A) = rank(B) = m Unique solution xrank(A) = rank(B) < m Many solutions xrank(A) < rank(B) No solutions x
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 43
-
9.3 Solutions to Systems of Equations 9 FUNCTIONS AND OPERATORS
9.3.2 Standard Square
Assume A is square and invertible, then
Ax = b x = A1b
9.3.3 Degenerated Square
9.3.4 Over-determined Rectangular
Assume A to be nm, n > m (tall) and rank(A) = m, then
Ax = b x = (AT A)1AT b = A+b
that is if there exists a solution x at all! If there is no solution the followingcan be useful:
Ax = b xmin = A+bNow xmin is the vector x which minimizes ||Ax b||2, i.e. the vector which isleast wrong. The matrix A+ is the pseudo-inverse of A. See [3].
9.3.5 Under-determined Rectangular
Assume A is nm and n < m (broad).
Ax = b xmin = AT (AAT )1b
The equation have many solutions x. But xmin is the solution which minimizes||Axb||2 and also the solution with the smallest norm ||x||2. The same holdsfor a matrix version: Assume A is nm, X is m n and B is n n, then
AX = B Xmin = A+B
The equation have many solutions X. But Xmin is the solution which minimizes||AXB||2 and also the solution with the smallest norm ||X||2. See [3].
Similar but different: Assume A is square n n and the matrices B0,B1are nN , where N > n, then if B0 has maximal rank
AB0 = B1 Amin = B1BT0 (B0BT0 )1
where Amin denotes the matrix which is optimal in a least square sense. Aninterpretation is that A is the linear approximation which maps the columnsvectors of B0 into the columns vectors of B1.
9.3.6 Linear form and zeros
Ax = 0, x A = 0
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 44
-
9.4 Matrix Norms 9 FUNCTIONS AND OPERATORS
9.3.7 Square form and zeros
If A is symmetric, then
xT Ax = 0, x A = 0
9.3.8 The Lyapunov Equation
AX + XB = C
vec(X) = (IA + BT I)1vec(C)See Sec 9.2.1 and 9.2.2 for details on the Kronecker product and the vec operator.
9.3.9 Encapsulating Sum
nAnXBn = C
vec(X) =(
nBTn An
)1vec(C)
See Sec 9.2.1 and 9.2.2 for details on the Kronecker product and the vec operator.
9.4 Matrix Norms
9.4.1 Definitions
A matrix norm is a mapping which fulfils
||A|| 0 ||A|| = 0 A = 0||cA|| = |c|||A||, c R
||A + B|| ||A||+ ||B||
9.4.2 Examples
||A||1 = maxj
i |Aij |||A||2 =
max eig(AT A)
||A||p = (max||x||p=1 ||Ax||p)1/p||A|| = maxi
j |Aij |
||A||F =
ij |Aij |2 =
Tr(AAH) (Frobenius)
||A||max = maxij |Aij |||A||KF = ||sing(A)||1 (Ky Fan)
where sing(A) is the vector of singular values of the matrix A.
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 45
-
9.5 Rank 9 FUNCTIONS AND OPERATORS
9.4.3 Inequalities
E. H. Rasmussen has in yet unpublished material derived and collected thefollowing inequalities. They are collected in a table as below, assuming A is anm n, and d = min{m, n}
||A||max ||A||1 ||A|| ||A||2 ||A||F ||A||KF||A||max 1 1 1 1 1||A||1 m m
m
m
m
||A|| n n
n
n
n||A||2
mn
n
m 1 1
||A||F
mn
n
m
d 1||A||KF
mnd
nd
md d
d
which are to be read as, e.g.
||A||2
m ||A||
9.5 Rank
9.5.1 Sylvesters Inequality
If A is m n and B is n r, thenrank(A) + rank(B) n rank(AB) min{rank(A), rank(B)}
9.6 Integral Involving Dirac Delta Functions
Assuming A to be square, then
p(s)(xAs)ds = 1det(A)
p(A1x)
Assuming A to be underdetermined, i.e. tall, then
p(s)(xAs)ds ={
1det(AT A)
p(A+x) if x = AA+x
0 elsewhere
}
See [8].
9.7 Miscellaneous
For any A it holds that
rank(A) = rank(AT ) = rank(AAT ) = rank(AT A)
It holds that
A is positive definite B invertible, such that A = BBT
9.7.1 Orthogonal matrix
If A is orthogonal, then det(A) = 1.
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 46
-
A ONE-DIMENSIONAL RESULTS
A One-dimensional Results
A.1 Gaussian
A.1.1 Density
p(x) =1
22exp
( (x )
2
22
)
A.1.2 Normalization
e
(s)222 ds =
22
e(ax
2+bx+c)dx =
aexp
[b2 4ac
4a
]
ec2x
2+c1x+c0dx =
c2 exp[c21 4c2c04c2
]
A.1.3 Derivatives
p(x)
= p(x)(x )
2
ln p(x)
=(x )
2
p(x)
= p(x)1
[(x )2
2 1
]
ln p(x)
=1
[(x )2
2 1
]
A.1.4 Completing the Squares
c2x2 + c1x + c0 = a(x b)2 + w
a = c2 b = 12c1c2
w =14
c21c2
+ c0
orc2x
2 + c1x + c0 = 122 (x )2 + d
=c12c2
2 =12c2
d = c0 c21
4c2
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 47
-
A.2 One Dimensional Mixture of GaussiansA ONE-DIMENSIONAL RESULTS
A.1.5 Moments
If the density is expressed by
p(x) =1
22exp
[ (s )
2
22
]or p(x) = C exp(c2x2 + c1x)
then the first few basic moments are
x = = c12c2x2 = 2 + 2 = 12c2 +
(c12c2
)2
x3 = 32 + 3 = c1(2c2)2[3 c212c2
]
x4 = 4 + 622 + 34 =(
c12c2
)4+ 6
(c12c2
)2 (12c2
)+ 3
(1
2c2
)2
and the central moments are
(x ) = 0 = 0(x )2 = 2 =
[12c2
]
(x )3 = 0 = 0(x )4 = 34 = 3
[1
2c2
]2
A kind of pseudo-moments (un-normalized integrals) can easily be derived as
exp(c2x2 + c1x)xndx = Zxn =
c2 exp[
c214c2
]xn
From the un-centralized moments one can derive other entities like
x2 x2 = 2 = 12c2x3 x2x = 22 = 2c1(2c2)2x4 x22 = 24 + 422 = 2(2c2)2
[1 4 c212c2
]
A.2 One Dimensional Mixture of Gaussians
A.2.1 Density and Normalization
p(s) =K
k
k22k
exp[1
2(s k)2
2k
]
A.2.2 Moments
An useful fact of MoG, is that
xn =
k
kxnk
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 48
-
A.2 One Dimensional Mixture of GaussiansA ONE-DIMENSIONAL RESULTS
where k denotes average with respect to the k.th component. We can calculatethe first four moments from the densities
p(x) =
k
k1
22kexp
[1
2(x k)2
2k
]
p(x) =
k
kCk exp[ck2x
2 + ck1x]
as
x = k kk =
k k
[ck12ck2
]
x2 = k k(2k + 2k) =
k k
[12ck2
+(ck12ck2
)2]
x3 = k k(32kk + 3k) =
k k
[ck1
(2ck2)2
[3 c2k12ck2
]]
x4 = k k(4k + 62k2k + 34k) =
k k
[(1
2ck2
)2 [(ck12ck2
)2 6 c2k12ck2 + 3
]]
If all the gaussians are centered, i.e. k = 0 for all k, then
x = 0 = 0x2 = k k2k =
k k
[12ck2
]
x3 = 0 = 0x4 = k k34k =
k k3
[12ck2
]2
From the un-centralized moments one can derive other entities like
x2 x2 = k,k kk[2k +
2k kk
]x3 x2x = k,k kk
[32kk +
3k (2k + 2k)k
]x4 x22 = k,k kk
[4k + 6
2k
2k + 3
4k (2k + 2k)(2k + 2k)
]
A.2.3 Derivatives
Defining p(s) =
k kNs(k, 2k) we get for a parameter j of the j.th compo-nent
ln p(s)j
=jNs(j , 2j )k kNs(k, 2k)
ln(jNs(j , 2j ))j
that is,
ln p(s)j
=jNs(j , 2j )k kNs(k, 2k)
1j
ln p(s)j
=jNs(j , 2j )k kNs(k, 2k)
(s j)2j
ln p(s)j
=jNs(j , 2j )k kNs(k, 2k)
1j
[(s j)2
2j 1
]
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 49
-
B PROOFS AND DETAILS
Note that k must be constrained to be proper ratios. Defining the ratios byj = erj /
k e
rk , we obtain
ln p(s)rj
=
l
ln p(s)l
lrj
wherelrj
= l(lj j)
B Proofs and Details
B.1 Misc Proofs
B.1.1 Proof of Equation 14
Essentially we need to calculate
(Xn)klXij
=
Xij
u1,...,un1
Xk,u1Xu1,u2 ...Xun1,l
= k,iu1,jXu1,u2 ...Xun1,l+Xk,u1u1,iu2,j ...Xun1,l
...+Xk,u1Xu1,u2 ...un1,il,j
=n1r=0
(Xr)ki(Xn1r)jl
=n1r=0
(XrJijXn1r)kl
Using the properties of the single entry matrix found in Sec. 8.2.4, the resultfollows easily.
B.1.2 Details on Eq. 67
det(XHAX) = det(XHAX)Tr[(XHAX)1(XHAX)]= det(XHAX)Tr[(XHAX)1((XH)AX + XH(AX))]= det(XHAX)
(Tr[(XHAX)1(XH)AX]
+Tr[(XHAX)1XH(AX)])
= det(XHAX)(Tr[AX(XHAX)1(XH)]
+Tr[(XHAX)1XHA(X)])
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 50
-
B.1 Misc Proofs B PROOFS AND DETAILS
First, the derivative is found with respect to the real part of X
det(XHAX)
-
REFERENCES REFERENCES
References
[1] Karl Gustav Andersson and Lars-Christer Boiers. Ordinaera differentialek-vationer. Studenterlitteratur, 1992.
[2] Jorn Anemuller, Terrence J. Sejnowski, and Scott Makeig. Complex inde-pendent component analysis of frequency-domain electroencephalographicdata. Neural Networks, 16(9):13111323, November 2003.
[3] S. Barnet. Matrices. Methods and Applications. Oxford Applied Mathe-matics and Computin Science Series. Clarendon Press, 1990.
[4] Christoffer Bishop. Neural Networks for Pattern Recognition. Oxford Uni-versity Press, 1995.
[5] Robert J. Boik. Lecture notes: Statistics 550. Online, April 22 2002. Notes.
[6] D. H. Brandwood. A complex gradient operator and its application inadaptive array theory. IEE Proceedings, 130(1):1116, February 1983. PTS.F and H.
[7] M. Brookes. Matrix Reference Manual, 2004. Website May 20, 2004.
[8] Mads Dyrholm. Some matrix results, 2004. Website August 23, 2004.
[9] Gene H. Golub and Charles F. van Loan. Matrix Computations. The JohnsHopkins University Press, Baltimore, 3rd edition, 1996.
[10] Robert M. Gray. Toeplitz and circulant matrices: A review. Technicalreport, Information Systems Laboratory, Department of Electrical Engi-neering,Stanford University, Stanford, California 94305, August 2002.
[11] Simon Haykin. Adaptive Filter Theory. Prentice Hall, Upper Saddle River,NJ, 4th edition, 2002.
[12] Thomas P. Minka. Old and new matrix algebra useful for statistics, De-cember 2000. Notes.
[13] L. Parra and C. Spence. Convolutive blind separation of non-stationarysources. In IEEE Transactions Speech and Audio Processing, pages 320327, May 2000.
[14] Laurent Schwartz. Cours dAnalyse, volume II. Hermann, Paris, 1967. Asreferenced in [11].
[15] Shayle R. Searle. Matrix Algebra Useful for Statistics. John Wiley andSons, 1982.
[16] G. Seber and A. Lee. Linear Regression Analysis. John Wiley and Sons,2002.
[17] S. M. Selby. Standard Mathematical Tables. CRC Press, 1974.
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 52
-
REFERENCES REFERENCES
[18] Inna Stainvas. Matrix algebra in differential calculus. Neural ComputingResearch Group, Information Engeneering, Aston University, UK, August2002. Notes.
[19] Max Welling. The kalman filter. Lecture Note.
Petersen & Pedersen, The Matrix Cookbook, Version: October 3, 2005, Page 53