Lesson 3 of 15
Rolling Statistics
Rolling Statistics
A rolling window calculation computes a statistic over a sliding fixed-size window of data. This is essential for detecting trends, smoothing noise, and measuring recent volatility in time series.
For a window of size applied to a series :
- Positions 0 through have fewer than values available → output
None - Position uses values through
Rolling Mean at position :
Rolling Std at position (sample standard deviation):
Your Task
Implement:
rolling_mean(xs, window)— list of rolling means,Nonefor firstwindow-1positionsrolling_std(xs, window)— list of rolling sample stds,Nonefor firstwindow-1positions
Python runtime loading...
Loading...
Click "Run" to execute your code.