Approximate percentile(近似百分位数(Approximate percentile))¶
Supported in: Batch
Returns the approximate percentile of the expression which is the smallest value in the ordered expression values (sorted from least to greatest) such that no more than percentage of expression values is less than the value or equal to that value.
Expression categories: Aggregate
Declared arguments¶
- Expression: Input expression.
Expression\ - Percentiles: Percentiles to calculate, if a single value is given, the output will be a double, if more than one value is provided, the output will be an array of doubles representing each percentile. Must range between 0 and 1.
List\> - optional Accuracy: The accuracy parameter (default: 10000) is a positive integer which controls approximation accuracy at the cost of memory. Higher value of accuracy yields better accuracy, 1.0/accuracy is the relative error of the approximation.
Literal\
Output type: Array\
Examples¶
Example 1: Base case¶
Argument values:
- Expression:
values - Percentiles: [0.5]
- Accuracy: null
Given input table:
| values |
|---|
| 2 |
| 4 |
| 3 |
Outputs: 3
Example 2: Base case¶
Argument values:
- Expression:
values - Percentiles: [0.33, 0.5, 0.66]
- Accuracy: null
Given input table:
| values |
|---|
| 2 |
| 4 |
| 3 |
| 5 |
| 1 |
Outputs: [ 2, 3, 4 ]
Example 3: Null case¶
Argument values:
- Expression:
values - Percentiles: [0.5]
- Accuracy: null
Given input table:
| values |
|---|
| null |
| null |
| null |
Outputs: null
Example 4: Null case¶
Argument values:
- Expression:
values - Percentiles: [0.5]
- Accuracy: null
Given input table:
| values |
|---|
| null |
| 1 |
| 3 |
Outputs: 1
中文翻译¶
近似百分位数(Approximate percentile)¶
支持:批处理(Batch)
返回表达式的近似百分位数,即在有序表达式值(从小到大排序)中,使得不超过指定百分比(percentage)的表达式值小于或等于该值的最小值。
表达式类别: 聚合(Aggregate)
声明的参数¶
- 表达式(Expression): 输入表达式。
表达式\<数值类型> - 百分位数(Percentiles): 要计算的百分位数。如果只提供一个值,输出为双精度浮点数(double);如果提供多个值,输出为表示每个百分位数的双精度浮点数数组。取值范围必须在 0 到 1 之间。
列表\<字面量\<双精度浮点数>> - 可选 精度(Accuracy): 精度参数(默认值:10000)是一个正整数,用于控制近似精度,但会以内存为代价。精度值越高,结果越精确,1.0/精度 即为近似的相对误差。
字面量\<整数>
输出类型: 数组\<数值类型> | 字节型 | 十进制数 | 双精度浮点数 | 单精度浮点数 | 整数型 | 长整型 | 短整型
示例¶
示例 1:基本情况¶
参数值:
- 表达式:
values - 百分位数: [0.5]
- 精度: null
给定输入表:
| values |
|---|
| 2 |
| 4 |
| 3 |
输出结果: 3
示例 2:基本情况¶
参数值:
- 表达式:
values - 百分位数: [0.33, 0.5, 0.66]
- 精度: null
给定输入表:
| values |
|---|
| 2 |
| 4 |
| 3 |
| 5 |
| 1 |
输出结果: [ 2, 3, 4 ]
示例 3:空值情况¶
参数值:
- 表达式:
values - 百分位数: [0.5]
- 精度: null
给定输入表:
| values |
|---|
| null |
| null |
| null |
输出结果: null
示例 4:空值情况¶
参数值:
- 表达式:
values - 百分位数: [0.5]
- 精度: null
给定输入表:
| values |
|---|
| null |
| 1 |
| 3 |
输出结果: 1