Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
一种快速计算R中矩阵滚动标准差的方法_R - Fatal编程技术网

一种快速计算R中矩阵滚动标准差的方法

一种快速计算R中矩阵滚动标准差的方法,r,R,我想找到一种计算矩阵滚动标准差的快速方法。为了准确地解释我的意思,我在下面模拟了一些代码,以准确地显示我在寻找什么。如你所知,这将是非常缓慢的 aaa <- matrix(1:1000,10,100) bbb <- aaa bbb[] <- NA tt.n <- 5 for (i in (tt.n:dim(aaa)[2])) { bbb[,i] <- apply(aaa[,(i-tt.n+1):i],1,sd) } 请参阅zoo包中

我想找到一种计算矩阵滚动标准差的快速方法。为了准确地解释我的意思,我在下面模拟了一些代码,以准确地显示我在寻找什么。如你所知,这将是非常缓慢的

aaa <- matrix(1:1000,10,100)
bbb <- aaa
bbb[] <- NA
tt.n <- 5

for (i in (tt.n:dim(aaa)[2]))
    {
    bbb[,i] <- apply(aaa[,(i-tt.n+1):i],1,sd)   
    }
请参阅zoo包中的rollapply。