TSDecay 函数

TSDecay 函数对其自变量计算衰变函数。

语法

TSDecay(current_value smallfloat, 
        initial_value  smallfloat, 
        decay_factor   smallfloat) 
returns smallfloat;

TSDecay(current_value double precision, 
        initial_value  double precision, 
        decay_factor   double precision) 
returns double precision;
current_value
当前数据(下一步显示的总和中的 vj)。
initial_value
初始值(下一步显示的总和中的 initial)。
decay_factor
衰变因子(下一步显示的总和中的 decay)。

描述

全部三个自变量必须是相同类型。

函数维护目前调用它所使用的所有自变量的总和。每次调用时,总和乘以提供的衰变因子。假设衰变因子在 0 与 1 之间,这将导致较旧自变量的重要性随时间降低。第一次调用 TSDecay 时,它将提供的初始值包括在运行总和中。TSDecay 计算的实际函数是:
                  i
((decayi)initial)+∑((vj)decayi-j)
                 j=i

在此计算中,i 是到目前为止调用函数的次数,vj 是在第 j 次调用中调用它所使用的值。

只有在 Apply 函数内使用时此函数才有用。

返回结果

衰变函数的结果。

示例

以下示例计算衰变:
create function ESA18(a smallfloat) returns smallfloat;
return (.18 * a) + TSDecay(.18 * a, a, .82);
end function;