# turicreate.SArray.rolling_stdv¶

SArray.rolling_stdv(window_start, window_end, min_observations=None)

Calculate a new SArray of the standard deviation of different subsets over this SArray.

The subset that the standard deviation is calculated over is defined as an inclusive range relative to the position to each value in the SArray, using window_start and window_end. For a better understanding of this, see the examples below.

Parameters: window_start : int The start of the subset to calculate the standard deviation relative to the current value. window_end : int The end of the subset to calculate the standard deviation relative to the current value. Must be greater than window_start. min_observations : int Minimum number of non-missing observations in window required to calculate the standard deviation (otherwise result is None). None signifies that the entire window must not include a missing value. A negative number throws an error. out : SArray

Examples

>>> import pandas
>>> sa = SArray([1,2,3,4,5])
>>> series = pandas.Series([1,2,3,4,5])


A rolling standard deviation with a window including the previous 2 entries including the current: >>> sa.rolling_stdv(-2,0) dtype: float Rows: 5 [None, None, 0.816496580927726, 0.816496580927726, 0.816496580927726]

Pandas equivalent: >>> pandas.rolling_std(series, 3, ddof=0) 0 NaN 1 NaN 2 0.816497 3 0.816497 4 0.816497 dtype: float64

Same rolling standard deviation operation, but 2 minimum observations: >>> sa.rolling_stdv(-2,0,min_observations=2) dtype: float Rows: 5 [None, 0.5, 0.816496580927726, 0.816496580927726, 0.816496580927726]

Pandas equivalent: >>> pandas.rolling_std(series, 3, ddof=0, min_periods=2) 0 NaN 1 0.500000 2 0.816497 3 0.816497 4 0.816497 dtype: float64

A rolling standard deviation with a size of 3, centered around the current: >>> sa.rolling_stdv(-1,1) dtype: float Rows: 5 [None, 0.816496580927726, 0.816496580927726, 0.816496580927726, None]

Pandas equivalent: >>> pandas.rolling_std(series, 3, center=True, ddof=0) 0 NaN 1 0.816497 2 0.816497 3 0.816497 4 NaN dtype: float64

A rolling standard deviation with a window including the current and the 2 entries following: >>> sa.rolling_stdv(0,2) dtype: float Rows: 5 [0.816496580927726, 0.816496580927726, 0.816496580927726, None, None]

A rolling standard deviation with a window including the previous 2 entries NOT including the current: >>> sa.rolling_stdv(-2,-1) dtype: float Rows: 5 [None, None, 0.5, 0.5, 0.5]