movingAverage() 函数
movingAverage()
使用当前值和 n - 1
个先前值计算 _values
列中非空值的平均值。
移动平均规则
- 由
n
个值填充的期间的平均值等于它们的代数平均值。 - 仅由
null
值填充的期间的平均值为null
。 - 移动平均值跳过
null
值。 - 如果
n
小于表中的记录数,则movingAverage()
返回可用值的平均值。
函数类型签名
(<-tables: stream[{A with _value: B}], n: int) => stream[{A with _value: float}] where B: Numeric
有关更多信息,请参阅 函数类型签名。
参数
n
(必需)要平均的值的数量。
tables
输入数据。 默认值为管道转发数据 (<-
)。
示例
计算三点移动平均值
import "sampledata"
sampledata.int()
|> movingAverage(n: 3)
计算包含空值的三点移动平均值
import "sampledata"
sampledata.int(includeNull: true)
|> movingAverage(n: 3)
此页是否对您有帮助?
感谢您的反馈!