quantile¶
- paddle. quantile ( x, q, axis=None, keepdim=False ) [source]
-
Compute the quantile of the input along the specified axis.
- Parameters
-
x (Tensor) – The input Tensor, it’s data type can be float32, float64.
q (int|float|list) – The q for calculate quantile, which should be in range [0, 1]. If q is a list, each q will be calculated and the first dimension of output is same to the number of
q.axis (int|list, optional) – The axis along which to calculate quantile.
axisshould be int or list of int.axisshould be in range [-D, D), where D is the dimensions ofx. Ifaxisis less than 0, it works the same way as \(axis + D\). Ifaxisis a list, quantile is calculated over all elements of given axises. Ifaxisis None, quantile is calculated over all elements ofx. Default is None.keepdim (bool, optional) – Whether to reserve the reduced dimension(s) in the output Tensor. If
keepdimis True, the dimensions of the output Tensor is the same asxexcept in the reduced dimensions(it is of size 1 in this case). Otherwise, the shape of the output Tensor is squeezed inaxis. Default is False.name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.
- Returns
-
Tensor, results of quantile along
axisofx. If data type ofxis float64, data type of results will be float64, otherwise data type will be float32.
Examples
import paddle x = paddle.randn((2,3)) #[[-1.28740597, 0.49533170, -1.00698614], # [-1.11656201, -1.01010525, -2.23457789]]) y1 = paddle.quantile(x, q=0.5, axis=[0, 1]) # y1 = -1.06333363 y2 = paddle.quantile(x, q=0.5, axis=1) # y2 = [-1.00698614, -1.11656201] y3 = paddle.quantile(x, q=[0.3, 0.5], axis=1) # y3 =[[-1.11915410, -1.56376839], # [-1.00698614, -1.11656201]] y4 = paddle.quantile(x, q=0.8, axis=1, keepdim=True) # y4 = [[-0.10559537], # [-1.05268800]])
