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
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: