Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-208

Nonlinearity Test Statistic

Problem

Compute a BDS-style nonlinearity statistic as C2 - C1^2, where C1 is the fraction of scalar pairs within radius (Chebyshev distance) and C2 the same fraction for two-dimensional delay vectors [x[t], x[t+1]].

Return 0.0 for fewer than three points or a non-positive radius. A nonzero value suggests nonlinear dependence.

Hint

Under iid data this statistic is approximately zero.

Test cases

case 1
in: [[1,2,3,4],0.5]
expected: 0
case 2
in: [[1,-1,1,-1],1]
expected: 0.2222222222222222
case 3
in: [[0,0,0],0.1]
expected: 0
case 4
in: [[1,2,3,4,5],2]
expected: 0.34333333333333343
Starter codePython
def nonlinearity_test_statistic(series, radius):
    # Your code here
    pass

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