gs_quant.timeseries.statistics.std¶
- std(x, w=<gs_quant.timeseries.helper.Window object>)[source]¶
Rolling standard deviation of series over given window
- Parameters:
x (
Series
) – series: timeseriesw (
Union
[Window
,int
,str
]) – Window or int: size of window and ramp up to use. e.g. Window(22, 10) where 22 is the window size and 10 the ramp up value. If w is a string, it should be a relative date like ‘1m’, ‘1d’, etc. 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