netsse.tools.misc_func.weighted_quantile#
- netsse.tools.misc_func.weighted_quantile(x, q, w, a=0.5, b=0.5, axis=-1)#
Computes the q-th quantiles of weighted data.
The quantiles are computed along one of the axes of the input array
x.- Parameters:
x (array_like) – Input data array for which the quantiles must be computed.
q (1d-array of shape (Nq,)) – Sequence of quantiles to compute, which must be between 0 and 1.
w (array_like) – Array of weights. The arrays
xandwmust be broadcastable.a (floats, default 0.5) – User-defined constant used in the computation of the quantiles. The default is 0.5 to minimize biases (Rogers, 2003).
b (floats, default 0.5) – User-defined constant used in the computation of the quantiles. The default is 0.5 to minimize biases (Rogers, 2003).
axis (integer, default -1) – Axis of
xalong which theq-quantiles are computed.
- Returns:
v – Values of the
q-quantiles computed along the specifiedaxisof the input arrayxwith weightsw.- Return type:
array_like
See also
weighted_stdComputes the weighted standard deviation of some data.
References
Rogers, J.W., 2003. Estimating the variance of percentiles using replicate weights, in: Proc. of the Joint Statistical Meetings, Survey Research Methods Section, American Statistical Association. pp. 3525–3532. URL: http://www.asasrms.org/Proceedings/y2003/Files/JSM2003-000742.pdf
Example
>>> v = weighted_quantile(x, q, w, a=0.5, b=0.5, axis=-1)