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.


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.

Return type:

Series, DataFrame, or ndarray


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:


© 2009–2012 Statsmodels Developers
© 2006–2008 Scipy Developers
© 2006 Jonathan E. Taylor
Licensed under the 3-clause BSD License.