AGGREGATION FUNCTION covariances(x, y, w){ static xmeans := 0., ymeans := 0., cnt := 0; if (cnt < w) { xmeans += x; ymeans += y; cnt+=1; } else { xmeans += (x - x.vec[cnt - w]) / w; ymeans += (y - y.vec[cnt - w]) / w; } avg (( x.vec(x.len-w, x.len) - xmeans ) * (y.vec(y.len - w, y.len) - ymeans )) }