Given the data set of n vectors xi = (xi,1, xi,2, ... , xi,m) ∈ ℝm, where i = 1,...,n, we can represent them by a n×m matrix X, such that each of the vectors xi, from the data set, is the i-th row of the matrix X. Given such data set (matrix) X, we can calculate the m×mcovariance matrixKXX whose (i, j) element is KXiXj = cov[Xi, Xj] = E[ (Xi - E[Xi]) ⋅ (Xj - E[Xj]) ] where Xi and Xj are the i-th and j-th columns of matrix X (dimension of the row vector x), and E is the expected value (mean).
Please Note:
Covariance is, by default, calculated as unbiased (sample), however, you can also choose a biased (population) version of calulation of KXX.