gs_quant.timeseries.statistics.zscores — gs_quant 0.1 documentation

# gs_quant.timeseries.statistics.zscores

`zscores`(x, w=<gs_quant.timeseries.helper.Window object>)

  Rolling z-scores over a given window

  Parameters

    - x (`Series`) – time series of prices

    - w (`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 z-scores

  Usage

  Calculate standard score of each value in series over given window. Standard deviation and sample mean are computed over the specified rolling window, then element is normalized to provide a rolling z-score:

  \(R_t = \frac { X_t - \mu }{ \sigma }\)

  Where \(\mu\) and \(\sigma\) are sample mean and standard deviation over the given window

  If window is not provided, computes z-score relative to mean and standard deviation over the full series

  Examples

  Generate price series and compute z-score of returns over \(22\) observations

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

  See also

  `mean()` `std()`