DescrStatsW.quantile(probs, return_pandas=True)[source]

Compute quantiles for a weighted sample.


probs : array-like

A vector of probability points at which to calculate the quantiles. Each element of probs should fall in [0, 1].

return_pandas : bool

If True, return value is a Pandas DataFrame or Series. Otherwise returns a ndarray.


quantiles : Series, DataFrame, or ndarray

If return_pandas = True, returns one of the following:
  • data are 1d, return_pandas = True: a Series indexed by the probability points.
  • data are 2d, return_pandas = True: a DataFrame with the probability points as row index and the variables as column index.

If return_pandas = False, returns an ndarray containing the same values as the Series/DataFrame.


To compute the quantiles, first, the weights are summed over exact ties yielding distinct data values y_1 < y_2 < ..., and corresponding weights w_1, w_2, .... Let s_j denote the sum of the first j weights, and let W denote the sum of all the weights. For a probability point p, if pW falls strictly between s_j and s_{j+1} then the estimated quantile is y_{j+1}. If pW = s_j then the estimated quantile is (y_j + y_{j+1})/2. If pW < p_1 then the estimated quantile is y_1.


SAS documentation for weighted quantiles: