如何计算相关矩阵? [英] How can i calculate correlation matrix?
本文介绍了如何计算相关矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个列为a, b, c
的表.可以使用函数形式计算cor[a;a]
,cor[a;b]
,cor[a;c]
的相关矩阵吗?
I have a table with columns a, b, c
. Can I calculate the correlation matrix of cor[a;a]
, cor[a;b]
, cor[a;c]
using functional form somehow?
?[table; (); 0b; (`aa`ab`ac)!((cor; `a; `a); (cor; `a; `b);(cor; `a; `b));
如何生成最后一个参数的列表?
(cor; a;
b)
How can i generate the list of the last argument?
(cor; a;
b)
推荐答案
因此手动键入表格:
q)t:([] a:10?10; b:10?10; c:10?10)
q)?[t;();0b;`aa`ab`ac!((cor;`a;`a);(cor;`a;`b);(cor;`a;`c))]
aa ab ac
-----------------------
1 -0.2530506 0.7966834
如果要生成最后一个参数,则假设您希望将第一列的所有排列与所有列组合在一起:
If you wanted to generate the last argument, assuming you wanted all permutations of first column combined with all columns:
q)a:{(`$raze'[string x])!(cor),/:x}{x[0],/:x}cols t;
q)?[t;();0b;a]
aa ab ac
-----------------------
1 -0.2530506 0.7966834
如果需要所有列排列:
q)a:{(`$raze'[string x])!(cor),/:x}{x cross x}cols t
q)?[t;();0b;a]
aa ab ac ba bb bc ca cb cc
----------------------------------------------------------------------
1 -0.2530506 0.7966834 -0.2530506 1 -0.268787 0.7966834 -0.268787 1
这篇关于如何计算相关矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文