比较三个对角线阵列并找出哪两个最相似

comparing three diagonal array and find which two are most similar

我有三个对角线数组 A,B,C 都是 double 大小 508X508。主对角线上方的所有值都不为零,并且每个其他单元格都为零。

A and B 中的数据都是在第 1 天和第 2 天从传感器收集的。同时,最优数据存储在C.

我的问题是如何找到哪个数组 A,BC 更相似 ???

实现该目标的最佳统计方法是什么,如果可能的话可能是 C# 代码快照?

我认为 Corak 为您指明了正确的道路。只是 select 一个距离度量,计算每个矩阵的距离总和。

尝试这样的事情

    public double ComputeArrayDistance(double[,] firstArray, double[,] secondArray)
    {
        // some quick and dirty guardClauses to prevent hedaches 
        if (firstArray.GetLength(0) != firstArray.GetLength(1)) throw new ArgumentException("the first array is not squared ..");
        if (secondArray.GetLength(0) != secondArray.GetLength(1)) throw new ArgumentException("the second array is not squared ..");
        if (firstArray.GetLength(0) != secondArray.GetLength(0)) throw new ArgumentException("the size of two array don't match");

        double totalDistance = 0; 

        // if the array(matrix) is lower triangular
        for(int i = 0; i < firstArray.GetLength(0); i++)
        {
            for(int j = 0; j <= i; j++ )
            {
                totalDistance += this.GetDistance(firstArray[i, j], secondArray[i, j]);
            }
        }

        return totalDistance;
    }

    private double GetDistance(double elemOne, double elemTwo)
    {
        // an acceptable measure should be the square of the difference  
        return Math.Pow((elemOne - elemTwo), 2);
    }