public static Correlation ( Matrix source, VectorType t = VectorType.Col ) : Matrix | ||
source | Matrix | Source for the. |
t | VectorType | (Optional) Row or Column sum. |
return | Matrix |
public static Matrix Correlation(Matrix source, VectorType t = VectorType.Col)
{
int length = t == VectorType.Row ? source.Rows : source.Cols;
Matrix m = new Matrix(length);
for (int i = 0; i < length; i++)
for (int j = i; j < length; j++) // symmetric matrix
m[i, j] = m[j, i] = source[i, t].Correlation(source[j, t]);
return m;
}
/// <summary>A Matrix extension method that correlations.</summary> /// <param name="source">The source to act on.</param> /// <param name="t">(Optional) Row or Column sum.</param> /// <returns>A Matrix.</returns> public static Matrix Correlation(this Matrix source, VectorType t = VectorType.Col) { return(Matrix.Correlation(source, t)); }