quantile() 函数
quantile()
从每个输入表中返回位于指定分位数内的值的行,或者返回包含表示指定分位数的值的行。
quantile()
支持包含浮点数值的列。
函数行为
quantile()
根据指定的 method
用作聚合或选择器转换。
- 聚合:当使用
estimate_tdigest
或exact_mean
方法时,quantile()
用作聚合转换,并输出位于指定分位数内的非空记录的平均值。 - 选择器:当使用
exact_selector
方法时,quantile()
用作选择器转换,并输出包含表示指定分位数的非空记录。
函数类型签名
(
<-tables: stream[A],
q: float,
?column: string,
?compression: float,
?method: string,
) => stream[A] where A: Record
有关更多信息,请参阅 函数类型签名。
参数
column
用于计算分位数的列。默认为 _value
。
q
(必需) 要计算的分位数。必须介于 0.0
和 1.0
之间。
method
计算方法。默认为 estimate_tdigest
。
可用方法:
- estimate_tdigest:聚合方法,它使用 t-digest 数据结构来计算大型数据源上的准确分位数估计。
- exact_mean:聚合方法,它采用最接近分位数值的两个点的平均值。
- exact_selector:选择器方法,它返回至少有
q
个点小于该值的行。
compression
压缩数据集时使用的质心数。默认为 1000.0
。
较大的数字会产生更准确的结果,但会增加内存需求。
tables
输入数据。默认为管道传输的数据 (<-
)。
示例
分位数作为聚合
import "sampledata"
sampledata.float()
|> quantile(q: 0.99, method: "estimate_tdigest")
分位数作为选择器
import "sampledata"
sampledata.float()
|> quantile(q: 0.5, method: "exact_selector")
此页面对您有帮助吗?
感谢您的反馈!