文档文档

median() function

median() 返回输入表或输入表中所有非空记录的_value中值,这些值落在 0.5 分位数(第 50 个百分位)内。

Function behavior

median()根据指定的method充当聚合或选择器转换。

  • 聚合:当使用estimate_tdigestexact_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!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more

InfluxDB 3 Open Source Now in Public Alpha

InfluxDB 3 Open Source is now available for alpha testing, licensed under MIT or Apache 2 licensing.

We are releasing two products as part of the alpha.

InfluxDB 3 Core, is our new open source product. It is a recent-data engine for time series and event data. InfluxDB 3 Enterprise is a commercial version that builds on Core’s foundation, adding historical query capability, read replicas, high availability, scalability, and fine-grained security.

For more information on how to get started, check out