Gram matrix
Consider
-vectors
. The Gram matrix of the collection is the
matrix
with elements
. The matrix can be expressed compactly in terms of the matrix
, as
![Rendered by QuickLaTeX.com \[G = X^{T}X = \begin{pmatrix} x_{1}^{T} \\ \vdots \\ x_{m}^{T} \end{pmatrix} \begin{pmatrix}x_{1} & \dots & x_{m} \end{pmatrix}.\]](https://ecampusontario.pressbooks.pub/app/uploads/quicklatex/quicklatex.com-c504c7bd65683a8ee1f3d1de8fa84fd9_l3.png)
By construction, a Gram matrix is always symmetric, meaning that
for every pair
. It is also positive semi-definite, meaning that
for every vector
(this comes from the identity
).
Assume that each vector ![]()
is normalized:
. Then the coefficient ![]()
can be expressed as
![]()
where
is the angle between the vectors
and
. Thus ![]()
is a measure of how similar
and
are.
The matrix
arises for example in text document classification, with ![]()
a measure of similarity between the
-th and
-th document, and
their respective bag-of-words representation (normalized to have Euclidean norm
).
See also: