我正在使用Nick Psaris的Funq,但需要一个null感知函数来生成协方差矩阵。我将使用它来创建一个马氏距离矩阵。他提供了一些支持null的函数:
navg = null感知平均
nvar null感知变量
nsvar = null感知样本变量
有什么建议吗?
发布于 2021-01-16 08:26:45
这是我的想法:
nSCovMatrix:{[matrix]
//takes table or array
//null aware Sample Covariance Matrix
$[98h=type matrix;matrix:"f"$(flip matrix[cols matrix]);matrix:"f"$matrix];
corMatrix:u cor/:\:u: flip matrix;
sd:sqrt nsvar[matrix]; //standard dev of each variable
diagMatrix:sd*{x=/:x}til first count each dataSet;
:covMatrix:(diagMatrix) mmu corMatrix mmu (diagMatrix);
};我找到相关矩阵,并将其转换为协方差矩阵,方法是取每个变量的stnd dev,与s.d.组成一个对角矩阵,然后将其与相关矩阵相乘两次。尽管还远未达到优化
https://stackoverflow.com/questions/65744381
复制相似问题