Previous topic

fynance.features.momentums.emstd

Next topic

fynance.features.momentums.wmstd

fynance.features.momentums.smstd

fynance.features.momentums.smstd(X, w=None, ddof=0, axis=0, dtype=None)

Compute simple moving standard deviation(s) for each X’ series’.

\[smstd^w_t(X) = \sqrt{\frac{1}{w}\sum^{w-1}_{i=0} (X_{t-i} - sma^w_t)^2}\]
Parameters:
X : np.ndarray[dtype, ndim=1 or 2]

Elements to compute the moving standard deviation.

w : int, optional

Size of the lagged window of the moving average, must be positive. If w is None or w=0, then w=X.shape[axis]. Default is None.

ddof : int, optional

Means Delta Degrees of Freedom, the divisor used in calculations is w - ddof (must be strictly positive), where w represents the number of elements in time axis. Default is 0.

axis : {0, 1}, optional

Axis along wich the computation is done. Default is 0.

dtype : np.dtype, optional

The type of the output array. If dtype is not given, infer the data type from X input.

Returns:
np.ndarray[dtype, ndim=1 or 2]

Simple moving standard deviation of each series.

See also

sma, wmstd, emstd

Examples

>>> X = np.array([60, 100, 80, 120, 160, 80])
>>> smstd(X, w=3, dtype=np.float64)
array([ 0.        , 20.        , 16.32993162, 16.32993162, 32.65986324,
       32.65986324])
>>> smstd(X.reshape([6, 1]), w=3, dtype=np.float64).flatten()
array([ 0.        , 20.        , 16.32993162, 16.32993162, 32.65986324,
       32.65986324])