YAMP.YMath.Correlation C# (CSharp) Method

Correlation() public static method

public static Correlation ( MatrixValue M ) : MatrixValue
M MatrixValue
return MatrixValue
        public static MatrixValue Correlation(MatrixValue M)
        {
            if (M.Length == 0)
            {
                return new MatrixValue();
            }

            var result = Covariance(M);

            for (var i = 1; i <= M.DimensionX; i++)
            {
                var temp = 1 / result[i, i].Sqrt();

                for (var j = 1; j <= M.DimensionX; j++)
                {
                    result[i, j] *= temp;
                    result[j, i] *= temp;
                }
            }

            return result;
        }

Usage Example

Exemplo n.º 1
0
 public MatrixValue Function(MatrixValue M)
 {
     return(YMath.Correlation(M));
 }