Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-030

Rolling Population Standard Deviation

Problem

Return the population standard deviation (denominator equals window) of every consecutive window of length window. Return an empty list when window <= 0 or window > len(data).

Hint

Same windows as a rolling mean, but return the square root of the population variance.

Test cases

case 1
in: [[1,2,3,4,5],3]
expected: [0.816496580927726,0.816496580927726,0.816496580927726]
case 2
in: [[2,2,2],2]
expected: [0,0]
case 3
in: [[1,2],2]
expected: [0.5]
case 4
in: [[1,2,3,4],2]
expected: [0.5,0.5,0.5]
case 5
in: [[10,12,14,16,18],3]
expected: [1.632993161855452,1.632993161855452,1.632993161855452]
Starter codePython
def rolling_std(data, window):
    # Your code here
    pass

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