gs_quant.timeseries.statistics.percentile¶
- percentile(x, n, w=None)[source]¶
Returns the nth percentile of a series.
- Parameters:
x (
Series
) – seriesn (
float
) – percentilew (
Union
[Window
,int
,str
,None
]) – 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.
- Return type:
Union
[Series
,float
]- Returns:
nth percentile
Usage
Calculates the nth percentile rank of \(x\). Rolling nth percentile is returned if a window is specified, else a scalar for nth percentile over the entire series.
Example
Compute the 90th percentile of a series.
>>> a = generate_series(100) >>> percentile(a, 90)