Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-118

Rolling Skewness

Problem

Compute the rolling population skewness with window size k: mean((x - window_mean)^3) / std^3, where std is the population standard deviation.

Return an empty list if k is not positive or exceeds the series; windows with zero variance produce 0.0.

Hint

Positive skewness means a long right tail.

Test cases

case 1
in: [[1,2,3,4,5],3]
expected: [0,0,0]
case 2
in: [[1,2,10],3]
expected: [0.6745554845457659]
case 3
in: [[1,1,1,2,10],3]
expected: [0,0.707106781186548,0.6745554845457659]
case 4
in: [[5,5,5],1]
expected: [0,0,0]
Starter codePython
def rolling_skewness(series, k):
    # Your code here
    pass

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