# Are there any functions that can determine the disorder between two lists?

dj11 = {1, 2, 3, 6, 5, 10, 15, 30, 7, 14, 21, 42, 35, 70, 105, 210,
11, 22, 33, 66, 55, 110, 165, 330, 77, 154, 231, 462, 385, 770,
1155, 2310};

dj12=Sort[dj11]

(* {1, 2, 3, 5, 6, 7, 10, 11, 14, 15, 21, 22, 30, 33, 35, 42, 55, 66,
70, 77, 105, 110, 154, 165, 210, 231, 330, 385, 462, 770, 1155, 2310} *)


I need to see if there is any way to determine the amount of disorder between the two lists dj11 and dj12 (i.e., how much complexity has been removed).

Motivation I am exploring the changes in complexity for the square-free numbers as we step through the integers. Square-free numbers are just the divisors of a primorial. Example (top view): $dj11 = \text{Join}(dj7, dj7 * p_{11})$.

• I can only see one list. May 22 '13 at 12:58
• what's the meaning the amount of disorder? something like Inversions in the Combinatorica? May 22 '13 at 13:01
• You can give a try with HammingDistance[dj11,Union[dj11]]... May 22 '13 at 13:02
• There is e.g. Signature[dj11], but more appropriate for your task would be: NeedlemanWunschSimilarity[ dj11, Sort@dj11], SmithWatermanSimilarity[ dj11, Sort@dj11] , DamerauLevenshteinDistance[ dj11, Sort@dj11]. May 22 '13 at 13:04
• How about saying what your real problem is? May 22 '13 at 13:19

Edit:

PearsonCorrelationTest is appropriate for checking the amount of variance in common between the original and the ordered lists.

dj11 = {1, 2, 3, 6, 5, 10, 15, 30, 7, 14, 21, 42, 35, 70, 105, 210,
11, 22, 33, 66, 55, 110, 165, 330, 77, 154, 231, 462, 385, 770, 1155, 2310};

dj12 = Ordering[dj11];

PearsonCorrelationTest[dj12, Range[Length[dj12]], "TestDataTable"]


0.923387^2


0.852644

There is an 85% overlap in the variance shared by the order of the elements in dj12 and the range 1...n.

ListPlot[{dj12, Range[Length[dj12]]}, AxesLabel -> {"Range[]", "dj12"}, BaseStyle -> 18]


• @FredKline. Actually, Correlation doesn't do just what I was looking for. I switched to PearsonCorrelationTest. May 22 '13 at 13:46
• What happens when dj11 and dj12 are compared? Can Correlation do anything when the numbers are identical, but in different positions? May 22 '13 at 13:50
• SpearmanRankTest`, which assumes ordinal rather than interval data, returns the same result as the Pearson test. May 22 '13 at 13:50