Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-116

Trend Significance Lite

Problem

Compute the standardized Mann-Kendall z score. Let S be the Mann-Kendall statistic and var = n(n-1)(2n+5)/18; applying a continuity correction, z = (S - 1)/sqrt(var) when S > 0, z = (S + 1)/sqrt(var) when S < 0, and 0 when S = 0.

Return 0.0 for fewer than three observations or zero variance.

Hint

Values of abs(z) above about 1.96 suggest a significant trend at 5 percent.

Test cases

case 1
in: [[1,2,3,4,5]]
expected: 2.2045407685048604
case 2
in: [[1,2,3]]
expected: 1.044465935734187
case 3
in: [[3,2,1]]
expected: -1.044465935734187
case 4
in: [[5,5,5,5]]
expected: 0
Starter codePython
def trend_significance_lite(series):
    # Your code here
    pass

4 test cases · run your code against them in the editor