# Covariance between two random matrices

I have two random matrices (matrix-valued random variables) $X$ and $Y$, both of dimension $n \times n$. Is there a notion of covariance between the two random matrices, i.e., $\text{Cov}(X,Y)$? If yes, how can I calculate it?

• By "random matrices" do you mean in the theoretical sense of matrix-valued random variables, or do you mean that each is an array of realizations of random variables? In the first sense your question cannot be answered except very generally (by quoting the definition) while in the second sense you simply haven't enough data. – whuber Mar 23 '16 at 18:04
• You could vectorize (stack the columns of) each matrix and consider the covariance matrix between the two resulting vectors. – Richard Hardy Mar 23 '16 at 18:11
• Hi Whuber, I actually mean matrix-valued random variable. – StellaLee Mar 23 '16 at 18:19

The most common thing to do is probably to simply consider the covariance between the entries of the matrices. Defining $\DeclareMathOperator{\vec}{\mathrm{vec}}\vec(A)$ to be the vectorization of a matrix $A$ (that is, stack up the columns into a single column vector), you can look at $\DeclareMathOperator{\Cov}{\mathrm{Cov}}\Cov(\vec(X), \vec(Y))$. This is then an $mn \times mn$ matrix.
If you preferred, you could instead define an $m \times n \times m \times n$ tensor, which would be essentially the same thing, just reshaped.
In e.g. the matrix normal distribution, we assume that the covariance matrix of the single random matrix $X$ factors as the Kronecker product of an $m \times m$ row covariance $U$ and an $n \times n$ column covariance $V$, in which case you can often just work with $U$ or $V$.
• @StellaLee To answer your comment-question in a comment (if it goes any further, you should ask this as a separate question): Note that $$\DeclareMathOperator{\E}{\mathbb E}\E[(X Y)_{ij}] = \E\left[\sum_k X_{ik} Y_{kj}\right] = \sum_k \E[X_{ik} Y_{kj}] = \sum_k \E[X_{ik}] \E[Y_{kj}] + \Cov(X_{ik}, Y_{kj}).$$ If you just want $\E[X Y]$, then doing it elementwise like this suffices, though if you want something like $\E[\lVert X Y \rVert]$ then it gets trickier. – Dougal Mar 23 '16 at 18:25