第一题
library(stats)
vectoer1 <- 1:100
my_window <- 3
stats::filter(vectoer1, rep(1,my_window))
filter:filter(x, expr),x为要过滤的对象,expr为过滤基础的表达式
vectoer:
rep:
第二题
x = C(249, 254, 243, 268, 253, 269, 287, 241, 273, 306, 303, 280, 260, 256, 278, 344, 304, 283, 310)
n = length(x)
S_1 = (sum(x^2)-n*(mean(x))^2)/(n-1)
S_2 = sum((x-mean(x))^2)/(n-1)
var(x)
Comments NOTHING