"Distance" between two permutations?

Solution 1:

What about involving (some sort of) $\text{L}^1$-norms of permutation matrices?

Let's create $3$ of such matrices, with each corresponding to the three cases a), b) and c), respectively $\pi_a$, $\pi_b$ and $\pi_c$. With $v$ standing for the $8 \times 1$ vector equal to $(1,2,3,4,5,6,7,8)'$, what follows is my suggestion

enter image description here

It considers as distance the sum of off-diagonal $1$s. Like David, "To my eye" the cases $v_c$ "looks like an extreme opposite" of $v$. However, $v_a$ is as far as $v_c$ from $v$. The closest one is $v_b$.


To comply with your intuition about the proximity between $v$ and $v_c$, one may want to drop out from our sum the $1$s being on the ante-diagonal, giving a problematic distance of $0$. That of $v_b$ from $v$ becomes $4$.


Using your first example, the distance that one obtains is $2$.

enter image description here

Solution 2:

In at least one way, your metric does penalize sublists that are in the wrong part of the sequence: a misplaced sublist of $n$ consecutive objects can add $n$ times as much to the "distance" as a single misplaced object, because you have to "move" $n$ objects from the misplaced sublist. It doesn't actually matter that the objects in the sublist were consecutive.

That's how your list $[5,6,7,8,1,2,3,4]$ ends up at distance $4$ from $[1,2,3,4,5,6,7,8],$ the same distance as from $[1,2,3,4,5,6,7,8]$ to $[5,1,6,2,7,3,8,4].$

Perhaps instead of moving individual objects, you want a single "move" to be able to move an entire sublist. That is, to convert $[5,6,7,8,1,2,3,4]$ to $[1,2,3,4,5,6,7,8]$ you can just take the sublist $[5,6,7,8]$ and move it to the end, so the distance is $1.$

I'm not sure why you would think $[8,7,6,5,4,3,2,1]$ should be "close" to $[1,2,3,4,5,6,7,8].$ To my eye it looks like an extreme opposite, although if you measured distance by counting swaps of objects (take two object out, leaving open space where they came from, then put each object into the other object's space), the distance would only be $4.$ Perhaps you want to count the reversal of a sublist (up to the length of the entire list) as a single "move."