median() function
median()
返回输入表或输入表中所有非空记录的_value
中值,这些值落在 0.5 分位数(第 50 个百分位)内。
Function behavior
median()
根据指定的method
充当聚合或选择器转换。
- 聚合:当使用
estimate_tdigest
或exact_mean
方法时,median()
充当聚合转换,并输出值落在 0.5 分位数(第 50 个百分位)内的非空记录的平均值。 - 选择器:当使用
exact_selector
方法时,meidan()
充当选择器转换,并输出具有代表 0.5 分位数(第 50 个百分位)的值的非空记录。
Function type signature
(<-tables: stream[A], ?column: string, ?compression: float, ?method: string) => stream[A] where A: Record
有关更多信息,请参阅 函数类型签名。
Parameters
column
用于计算中值的列。 默认为_value
。
method
计算方法。 默认为estimate_tdigest
。
Available methods:
- estimate_tdigest: 聚合方法,使用 t-digest 数据结构 来计算大型数据源上准确的中位数估计值。
- exact_mean: 聚合方法,取最接近中位数的两个点的平均值。
- exact_selector: 选择器方法,返回至少 50% 的点小于其值的行。
compression
压缩数据集时使用的质心数。默认为 0.0
。
更大的数字会产生更准确的结果,但会增加内存需求。
tables
输入数据。默认为管道式数据 (<-
)。
Examples
使用中位数作为聚合转换
import "sampledata"
sampledata.float()
|> median()
使用中位数作为选择器转换
import "sampledata"
sampledata.float()
|> median(method: "exact_selector")
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, use the following resources
Customers with an annual or support contract can contact InfluxData Support.