gs_quant.timeseries.statistics.mean¶
- mean(x, w=<gs_quant.timeseries.helper.Window object>)[source]¶
Arithmetic mean of series over given window
- Parameters:
x (
Union
[Series
,List
[Series
]]) – series: a timeseries or an array of 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 mean value
Usage
Calculates arithmetic mean of the series over a rolling window
If a timeseries is provided:
\(R_t = \frac{\sum_{i=t-w+1}^{t} X_i}{N}\)
where \(N\) is the number of observations in each rolling window, \(w\).
If an array of timeseries is provided:
\(R_t = \frac{\sum_{i=t-w+1}^{t} {\sum_{j=1}^{n}} X_{ij}}{N}\)
where \(n\) is the number of series, and \(N\) is the number of observations in each rolling window, \(w\).
If window is not provided, computes rolling mean over the full series. If the window size is greater than the available data, will return mean of available values.
Examples
Generate price series and compute mean over \(22\) observations
>>> prices = generate_series(100) >>> mean(prices, 22)
See also