[Math] How to measure monotonicity of a list of values

algebra-precalculuscalculusnumber theory

I need to compare monotonicity of lists of values.

I have $S=(n_1,n_2,…n_n)$, I need a function $\mathrm f(S)$ to return the monotonicity of the S.

$S_1=[1,2,4,4,8]$

$S_2=[8,4,4,2,1]$

$S_3=[2,1,4,4,8]$

$S_4=[1,4,8,2,4]$

Requirement:
$f(S_1) = f(S_2) > f(S_3) > f(S_4)$

Update Question

$S_5 = [1,4,1,8]$

$S_6 = [1,4,2,8]$

$S_7 = [1,4,4,8]$

$S_8 = [1,4,6,8]$

$S_5 < S_6 < S_7 < S_8$

Best Answer

How about

$$ -\sum_{i=1}^{n-1} \frac{\lvert n_i-n_{i+1} \rvert}{\max(\lvert n_i \rvert, \lvert n_{i+1} \rvert) } $$

That is: summing relative gaps.

(Considering $0/0$ to be 0.)

Related Question