This function is for calculating triangular moving averages. In fact, this function equals to using function Movavg twice with backward and 0 forward. Thus, at point = i, the triangular moving average value is:
where and .
vector tmovavg(vector vd, int n[, int missing])
vd
n
missing
Return the triangular moving average vector.
Example 1
// Col(2) will be filled with triangular moving average value at each point, //with stating point = 9. for(ii=1;ii<=30;ii++) col(1)[ii] = ii; col(2)=tmovavg(col(1),9);
Example 2
newbook; col(A) = {4,8,6,-1,NAN,-3,-1, 3, 4, 5}; col(B) = tmovavg(col(A),3,0); //returns [-- -- 6.5 4.75 0.75 -2 -2.5 -0.5 2.25 4] col(C) = tmovavg(col(A),3,1); //returns [-- -- 6.5 4.75 -- -- -- -0.5 2.25 4] col(D) = tmovavg(col(A),3,2); //returns [-- -- 6.5 4.75 -- -3 -2.5 -0.5 2.25 4]