Skip to content
DeepForgeby svx
All problems
EasyTime Seriests-240

Rolling Stats Features

Problem

Compute the mean and population standard deviation of the most recent window of the series as [mean, std].

Return an empty list if window is not positive or exceeds the series length.

Hint

Window statistics are a cheap hand-crafted feature set for neural models.

Test cases

case 1
in: [[1,2,3,4,5],3]
expected: [4,0.816496580927726]
case 2
in: [[5,5,5],2]
expected: [5,0]
case 3
in: [[1,2],0]
expected: []
case 4
in: [[1,2,3],3]
expected: [2,0.816496580927726]
Starter codePython
def rolling_stats_features(series, window):
    # Your code here
    pass

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