众所周知,计算相关性非常的简单,因为R 语言中有函数cor.test(),该函数可以计算多种方法的相关性检验,返回相关性,Pvalue 等检验值,但是这个函数在Julia中并不存在,让 Julia 作为一门科学计算语言显得并不完美。
首先,我们来看一下 R 语言计算线性相关的结果是什么样子的?
1 2 3 4
a<-c(1,3,4,5,7) b<-c(2,4,6,8,9) c<-cor.test(a,b) c
1 2 3 4 5 6 7 8 9 10
Pearson's product-moment correlation data: a and b t = 7.7771, df = 3, p-value = 0.004423 alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval: 0.6757774 0.9984873 sample estimates: cor 0.976086