Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-200

Detrended Fluctuation

Problem

Compute a single-scale detrended fluctuation. Integrate the mean-adjusted series into a profile, detrend the profile with an OLS line against time, and return the root mean squared residual.

Return 0.0 for fewer than two points.

Hint

Detrending the integrated profile removes slow drift before measuring fluctuation.

Test cases

case 1
in: [[1,2,3,4,5]]
expected: 0.8366600265340756
case 2
in: [[5,5,5]]
expected: 0
case 3
in: [[1,-1,1,-1]]
expected: 0.4472135954999579
case 4
in: [[1,2,1,2,1,2]]
expected: 0.2390457218668787
Starter codePython
def detrended_fluctuation(series):
    # Your code here
    pass

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