roll_standardize

Defined in fynance.features.scale

roll_standardize(X, w=None, a=0, b=1, axis=0, kind_moment='s')[source]

Substitutes the rolling mean and divid by the rolling standard dev.

\[RollStandardize(X)^w_t = b \times \frac{X_t - RollMean(X)^w_t} {RollStd(X)^w_t} + a\]
Parameters:
Xnp.ndarray[dtype, ndim=1 or 2]

Data to scale.

wint, optional

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

a, bfloat or array_like, optional

Respectively an additional and multiply factor.

axisint, optional

Axis along which to scale the data.

kind_momentstr {“s”, “w”, “e”}, optional
  • If “s” (default) then compute basic moving averages and standard deviations, see sma and smstd.

  • If “w” then compute the weighted moving averages and standard deviations, see wma and wmstd.

  • If “e” then compute the exponential moving averages and standard deviations, see ema and emstd.

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

The scaled data.

See also

Scale, normalize, standardize, roll_standardize