gs_quant.timeseries.statistics.mode

mode(x, w=<gs_quant.timeseries.helper.Window object>)[source]

Most common value in series over given window

Parameters:
  • x (Series) – series: timeseries

  • 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 mode value

Usage

Computes the mode over a given window. For each window, this function will return the most common value of all elements in the window. If there are multiple values with the same frequency of occurrence, will return the smallest value.

If window is not provided, computes mode over the full series.

Examples

Generate price series and compute mode over \(22\) observations

>>> prices = generate_series(100)
>>> mode(prices, 22)

See also

mean() median()