exponential_std¶
-
exponential_std
(x, alpha=0.75)[source]¶ Exponentially weighted standard deviation time series from previous values.
- Parameters
x (
Series
) – time series of pricesalpha (
float
) – how much to weigh the previous price in the time series, thus controlling how much importance we place on the (more distant) past
- Return type
Series
- Returns
date-based time series of standard deviation of the input series
Usage
Provides unbiased estimator of exponentially weighted sample standard deviation:
\(R_t = \sqrt{ \frac{\sum_{i=0}^t w_i (X_{t-i} - \overline{X_t})^2} {\sum_{i=0}^t w_i} * DF_t }\)
where \(w_i\) is the weight assigned to \(i\) th observation, \(\overline{X_t}\) is the day’s exponential moving average and \(DF_t\) is the debiasing factor:
\(w_i = (1-\alpha)\alpha^i\) for i<t; \(\alpha^i\) for i=t
\(\overline{X_t} = \alpha \cdot \overline{X_{t-1}} + (1 - \alpha) \cdot X_{t-1}\)
\(DF_t = \frac{(\sum_{i=0}^t w_i)^2} {(\sum_{i=0}^t w_i)^2 - \sum_{i=0}^t w_i^2}\)
Examples
Generate price series and compute exponentially weighted standard deviation of returns
>>> prices = generate_series(100) >>> exponential_std(returns(prices), 0.9)
See also