experimental.quantile() 函数
experimental.quantile()
是随时可能更改的实验性软件包。
experimental.quantile()
返回在 _value
列中,其值落在指定分位数内或表示指定分位数的非空记录。
_value
列必须包含浮点值。
计算方法和行为
experimental.quantile()
的行为类似于聚合函数或选择器函数,具体取决于 method
参数。 以下计算方法可用:
estimate_tdigest
一种聚合方法,它使用 t-digest 数据结构来计算大型数据源上的准确分位数估计。 使用时,experimental.quantile()
输出值落在指定分位数内的非空记录。
exact_mean
一种聚合方法,它取最接近分位数值的两个点的平均值。 使用时,experimental.quantile()
输出值落在指定分位数内的非空记录。
exact_selector
一种选择器方法,它返回至少有 q
个点小于的数据点。 使用时,experimental.quantile()
输出值表示指定分位数的非空记录。
函数类型签名
(
<-tables: stream[{A with _value: float}],
q: float,
?compression: float,
?method: string,
) => stream[{A with _value: float}]
有关更多信息,请参阅函数类型签名。
参数
q
(必需) 要计算的分位数 ([0 - 1]
)。
method
计算方法。默认为 estimate_tdigest
。
支持的方法:
- estimate_tdigest
- exact_mean
- exact_selector
compression
压缩数据集时要使用的质心数量。默认为 1000.0
。
更大的数字会产生更准确的结果,但会增加内存需求。
tables
输入数据。默认情况下为管道传输的数据 (<-
)。
示例
返回每个输入表第 50 个百分位数值
import "experimental"
import "sampledata"
sampledata.float()
|> experimental.quantile(q: 0.5)
返回一个代表每个输入表的第 50 个百分位数值
import "experimental"
import "sampledata"
sampledata.float()
|> experimental.quantile(q: 0.5, method: "exact_selector")
此页面是否对您有帮助?
感谢您的反馈!