美文网首页python学生信
permutation test及R语言实现

permutation test及R语言实现

作者: 一只烟酒僧 | 来源:发表于2020-06-21 16:22 被阅读0次

    必看1:http://www.iikx.com/news/statistics/1824.html
    必看2:https://www.plob.org/article/3176.html
    https://blog.csdn.net/ARPOSPF/article/details/86649066

    两个函数备注
    diff():计算向量中两元素的差值,包含三个参数:x,向量或矩阵,如果是矩阵,则按照列计算差值;lag,默认是1,默认计算间隔为1的两个元素的差值;differences,默认为1,默认只计算一次差值,不会再累计计算
    https://likan.info/cn/post/diff-function-in-r/

    > diff(1:5)
    [1] 1 1 1 1
    
    > diff(1:5,lag=2)
    [1] 2 2 2
    
    > diff(1:5,differences=2)
    [1] 0 0 0
    
    > diff(matrix(1:20,nrow = 5))
         [,1] [,2] [,3] [,4]
    [1,]    1    1    1    1
    [2,]    1    1    1    1
    [3,]    1    1    1    1
    [4,]    1    1    1    1
    

    replicate,与rep类似,进行重复取值,区别是:1、replicate中重复次数设置是第一个参数,rep是第二个;2、rep中输入不是向量化,没有办法更新,而replicate可以
    https://www.jianshu.com/p/7d7862c72c4a

    rep(runif(1),5)
    #[1] 0.7548687 0.7548687 0.7548687 0.7548687 0.7548687
    
    replicate(5,runif(1))
    [1] 0.5315511 0.9896081 0.1711190 0.4024064 0.7224799
    

    相关文章

      网友评论

        本文标题:permutation test及R语言实现

        本文链接:https://www.haomeiwen.com/subject/brdaxktx.html