std

std(x, w=Window(w=None, r=0))[source]

Rolling standard deviation of series over given window

Parameters
  • x (Series) – series: timeseries

  • w (Union[Window, int]) – Window or int: number of observations and ramp up to use. e.g. Window(22, 10) where 22 is the window size and 10 the ramp up value. Window size defaults to length of series.

Return type

Series

Returns

timeseries of standard deviation

Usage

Provides unbiased estimator of sample standard deviation over a rolling window:

\(R_t = \sqrt{\frac{1}{N-1} \sum_{i=t-w+1}^t (X_i - \overline{X_t})^2}\)

where \(N\) is the number of observations in each rolling window, \(w\), and \(\overline{X_t}\) is the mean value over the same window:

\(\overline{X_t} = \frac{\sum_{i=t-w+1}^{t} X_i}{N}\)

If window is not provided, computes standard deviation over the full series

Examples

Generate price series and compute standard deviation of returns over \(22\) observations

>>> prices = generate_series(100)
>>> std(returns(prices), 22)

See also

sum() mean() var()