how to compute the "Hamming total" of a symmetric group?

75 Views Asked by At

The Hamming distance between two binary numbers has an obvious analogue for numbers encoded using a base $\gt 2$. A different analogue is the following.

Let $\sigma \in S_n$ be a permutation which operates on the set $\{1,2 \dots,n\}$. then define: $$ \phi(\sigma) = \sum_{j=1}^n |\sigma(j)-j| $$ Q1. What is the usual name and symbol employed to refer to this function?

Q2. What is the value of $$H(n)=\sum_{\sigma \in S_n} \phi(\sigma)$$

Note: $H(1)=0, H(2)=2, H(3)=16$

2

There are 2 best solutions below

1
On BEST ANSWER

I can't say much at all about Q1 (see the comment under OP). Q2 can be settled by changing the order of summation.

We know that to any pair of integers $i,j\in\{1,2,\ldots,n\}$ there are exactly $(n-1)!$ permutations $\sigma\in S_n$ such that $\sigma(j)=i$. Therefore we can calculate the sum as follows. $$ \begin{aligned} H(n)&=\sum_{\sigma\in S_n}\sum_{j=1}^n|\sigma(j)-j|\\ &=\sum_{j=1}^n\sum_{\sigma\in S_n}|\sigma(j)-j|\\ &=\sum_{j=1}^n\sum_{i=1}^n\left((n-1)!|i-j|\right)\\ &=(n-1)!\sum_{j=1}^n\sum_{i=1}^n|i-j|\\ &=(n-1)!\sum_{j=1}^n\left(\sum_{i=1}^j(j-i)+\sum_{i=j+1}^n(i-j)\right)\\ &=(n-1)!\sum_{j=1}^n\left(\frac{j(j-1)}2+\frac{(n-j)(n-j+1)}2\right)\\ &=(n-1)!\sum_{j=1}^nj(j-1)\\ &=(n-1)!\left(\frac{n(n-1)(n+1)}3\right).\\ \end{aligned} $$

The first step was just the change of summation order. In the second step I utilized the observation about the number of permutations with the property $\sigma(j)=i$.

In the next to last step I made the observation that the two parts yield identical sums but in reverse order. The last step can be done in many ways. Either by using the known formulas for $\sum_j j$ and $\sum_j j^2$, or by identifying the summands as $2{j\choose 2}$, placing them along a diagonal in Pascal's triangle, and using the Pascal triangle rule.

As a further reality check we see that the formula agrees with your calculations in the cases $n=1,2,3$.

0
On

This answer is wrong!
The final answer should be multiplied by $n!$, because I only calculated the average distance 'travelled' by an number. Also, $P(\sigma(i)=i)\neq P(\sigma(i)=j)$ for some $j\neq i$.

Suppose that $S_n$ permutes $\{1,2,\dots, n\}$. Then, we know, because of symmetry, that the average distance that $1$ will travel to it's new position is $\frac {n+1}2-1$. The average destination is $\frac{n+1}2$, and because you are already at $1$ (and not at $0$), you only need $\frac{n-1}2$ steps. For a number $i$, the average position if it moves to the left (a strictly lower number) is $\frac{i-1}2$. The distance to travel is $\frac{i-1}2$, because now, you start outside the interval. When $i$ moves to the right or stays in its place, you get the average position $\frac{n-(i-1)}2+i=\frac{n+i+1}2$. Because you are already inside the interval, the average distance to travel is $\frac{n+i+1}2-1=\frac{n+i-1}2$. The probability of going to the left is $\frac{i-1}n$ and the rest is $\frac{n-i+1}n$. For the average distance travelled by $i$, we get $$ \frac{i-1}n\frac{i-1}2+\frac{n-i+1}n\frac{n+i-1}2 =\frac{(i-1)^2+n^2-(i-1)^2}{2n} =\frac n2 $$ Now, we sum over all $i$: $$ H(n)=\sum_{i=1}^n\frac n2=n\frac n2=\frac 12 n^2 $$

I don't know a common name for this expression.