| # 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 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: Bag-of-words representation of text. Bag-of-words representation of text: measure of document similarity.