Sum of Traces of all Permutations of a Matrix

combinatoricsmatricespermutation-cyclespermutation-matricespermutations

I have a problem that reduces to finding the sum of the traces of all possible row permutations of a large matrix. For example if we had a 3×3 matrix, the possible row orderings would be (1,2,3),(1,3,2),(2,1,3),(2,3,1),(3,1,2),(3,2,1), where the numbers represent the original row numbers. I want to find the sum of the Traces over all possible orderings.

I could calculate them all but that would scale at N!, which is too computationally expensive. Is there a way to simplify the problem? Or to approximate the answer without performing each computation?

Some extra information

The matrix represents probabilities so that all rows and columns sum to 1. And I know that the Trace of the original matrix is the largest term in the sum. (If any of that helps). Also, what I am actually trying to do is maximise the sum with respect to a parameter, lambda, which is used in a function to calculate the elements in the matrix. So if you want to transform the sum using an increasing function and maximise/calculate that instead then that would work too.

Best Answer

First of all, I claim that the sum of all order $n$ permutations matrices is equal to the matrix whose entries are all equal to $(n-1)!$. This is because for each $1\le i \le n$ and $1\le j\le n$, the number of permutations for which $\pi(i)=j$ is $(n-1)!$.

Another way of writing this constant matrix is $(n-1)!\def\1{{\bf1}}\1\1^T$, where $\1$ is a column vector of all ones.

Therefore, letting $B$ be any fixed $n\times n$ matrix, and $A_\pi$ be the permutations matrix corresponding to $\pi$, then \begin{align} \sum_{\pi\in S_n}\mathrm{tr}(A_\pi B) &=\mathrm{tr}\left(\left(\sum_{\pi}A_\pi\right)B\right) \\&=\mathrm{tr}\big((n-1)!\1\1^TB\big) \\&=(n-1)!\mathrm{tr}(\1^TB\1) \end{align} The last equality is the cyclic property of trace. Finally, $\mathrm{tr}(\1^TB\1)$ is the sum of the entries of $B$. Therefore, the sum of the traces of the permutations of a matrix is equal to $(n-1)!$ times the sum of the entries of that matrix.

Related Question