As I was contemplating the metric I came up with yesterday for measuring the 'spread' of a list, I realised that it isn't actually all that great.
For example, take
This looks pretty good and would have a score of 8.
This definitely looks inferior and yet has the same score of 8.
Need to do better!
Instead I started considering nearest elements. So, for each element, we sum the distance to the nearest similar element in the list. Then we can add them all up.
Now, when we consider the first case we instead get a score of
2 + 2 + 2 = 6
while the second case gives
1 + 1 + 3 = 5
Definitely an improvement there - the 'better by eye' version is now scoring better.
I wanted to check that it did indeed make sense for other situations though.
[2,1,2] -> 2 + 2 = 4 [1,2,2] -> 1 + 1 = 2 [2,1,3,2,5,6,7,2] -> 3 + 3 + 4 = 10 [2,2,1,3,5,6,7,2] -> 1 + 1 + 6 = 8
This certainly looks better now.
I think I'm confident enough to now go away and code something up in order to investigate more thoroughly.