# How to measure how well a list of numbers is uniformly decreasing?

I have a list of numbers that I want to measure how well are sorted/decrease. I want something more detailed than simply inversion, I want to know how uniformly they decrease.

For examples, the list (10,8,6,4,2,0) should have a higher score than (10,9,8,,3,2,1).

(10,8,6,4,2,0) and (10, 8, 6, 7, 4, 2) should both have a higher score than (10.5,10.4,10.3, 10.1, 8, 6).

In other words, I want to measure how well the numbers descend, and also I want to favour the magnitude of descending.

My idea is to assign each number an index, and then to measure the correlation. However, what kind of correlation would I want? Should it be Pearson since I am looking for a linear correlation. Or is there a better method?

More info: In some tests I have done Pearson gave the list [10.91, 4.84, 4.75, 4.75, 4.397, 4.37, 3.85, 3.05, 3.05] a lower correlation than the list [14.71, 14.71, 14.71, 10.15, 10.15, 10.17, 10.22, 10.22, 10.22].

The first list is more desirable to me since the range is bigger - we can see the list is descending more strongly. Should I use spearmans rank instead? If so, why?

• Could you clarify your rationale for the second example, why and how exactly (10, 8, 6, 7, 4, 2) is "better" than (10.5,10.4,10.3, 10.1, 8, 6)..?
– Tim
Aug 3 at 16:00
• @Tim Hi Tim, sure. The range is bigger, and the slope of the descent is bigger. Basically, I want to reward lists with a broad range from a large number that steadily go down to zero. Aug 3 at 16:06

Convert to differences, so (10, 8, 6, 4, 2, 0) = (-2, -2, -2, -2, -2) and (10, 8, 6, 7, 4, 2) = (-2, -2, 1, -3, -2). Find mean, variance, and standard deviation, and relative standard deviation (aka coefficient of variation) for each list. Lower relative standard deviation means more uniform descent, higher relative standard deviation means less uniform descent.

If you want to also penalize lists having individually smaller decreases, construct a composite score of these two important aspects. Use mean difference of each list as a weight in the final score, scaling it however you need, e.g., final score = mean difference - 2 * relative standard deviation, in which case score of (10,8,6,4,2,0) = 2, (10,8,6,7,4,2) = -1.11, (10.5,10.4,10.3,10.1,8,6)= -0.98, and as desired (10,8,6,4,2,0) is better than (10,8,6,7,4,2), both of which are better than (10.5,10.4,10.3,10.1,8,6).

• I would suggest the same (+1), but it doesn't work for the second example.
– Tim
Aug 3 at 16:01
• Thanks. However, if all the differences between the numbers are very small I also want to penalise that. e.g. if all the list was (10,10,10,11,11,11) your method would favour that list more highly vs. (10,9,8,3,2,1). I want to favour a broad range as well as a uniform descent. Aug 3 at 16:08
• @twigface you could also compute the 2nd order difference by filtering the 1st order difference with [1,-1] or by filtering the original list with [1,-2,1]. This should give more information than the 1st order difference alone. Aug 3 at 16:10
• @mhdadk sorry I don't quite understand your suggestion about "filtering". Is there a name for this process I could look up? Aug 3 at 16:12
• @twigface by "filtering", I meant discrete convolution. Aug 3 at 21:31

As @C8H10N4O2 noticed, you are interested in differences between consecutive numbers. You want the differences to be small and you want them to be "uniform", not to vary too much. It seems like you want to measure two things. The first thing can be easily measured by looking at the mean of the differences. The second thing, by looking at the standard deviation of the differences.

> x1 <- c(10,8,6,4,2,0)
> x2 <- c(10,9,8,3,2,1)
> x3 <- c(10, 8, 6, 7, 4, 2)
> x4 <- c(10.5,10.4,10.3, 10.1, 8, 6)
> s <- function (x) c(mean=mean(diff(x)), sd=sd(diff(x)))
> s(x1)
mean   sd
-2    0
> s(x2)
mean        sd
-1.800000  1.788854
> s(x3)
mean        sd
-1.600000  1.516575
> s(x4)
mean       sd
-0.90000  1.05119


Of course, you can combine the two statistics, for example, use something as coefficient of variation or calculate the weighted sum of them. The question to ask yourself is how important are both criteria? Would you apply the same weights to both? Even if you choose some statistic that measures both things at the same time, it likely will penalize one of them stronger than another, so you need to ask yourself this question.

• Thanks for the thoughtful response Tim. These are great ideas. However, I think both of these metrics ignore the range, which is also a very important criteria. If you look at my edited OP you can see another example there. Surely, there must be some linear function that exists to measure this kindof thing? It seems like it should be so trivial haha! Edit: on second thoughts no, the mean in some way measures the "range", right? the higher the mean, the more on average the numbers have traversed. Aug 3 at 16:29
• @twigface what do you mean by range? If you mean max - min, you can use it instead of sd as another way of measuring variability.
– Tim
Aug 3 at 16:49
• Yeah I do mean that. Yeah that seems like it would work but would require some kind-of bias from me to weight them, especially considering how different the scales would be. Good idea though - thank you! Aug 3 at 16:52
• You can look for a statistic that does both, but this only means that someone made a decision for you how to “weight” them. You want to measure two things, you can’t escape from the decision @twigface
– Tim
Aug 3 at 17:01
• for my case CV doesn't seem too good. The absolute mean difference is often between 0-2, often closer to 0. Also the differences can be positive or negative (although mostly negative as we've seen in my examples). Therefore the CV is not particularly useful and overshadows the mean difference a lot. I think for simplicity & interpretability, simple mean difference is what I will use. Thanks for all yours and @C8H10N4O2 help! Aug 5 at 14:33