You can use the Pearsons correlation to compute the elements of a correlation matrix:
I am sure this is not the fastest method and ignores the fact that the matrix could be better implemented with a square symmetric matrix but show how to get started
public static Matrix<double> Correl(Matrix<double> x)
I am sure this is not the fastest method and ignores the fact that the matrix could be better implemented with a square symmetric matrix but show how to get started
public static Matrix<double> Correl(Matrix<double> x)
{
Matrix<double> correlM = new DenseMatrix(x.RowCount, x.RowCount);
//off diagonal elements
foreach (var rowx in x.RowEnumerator())
{
foreach (var rowy in x.RowEnumerator())
{
if (rowy.Item1 > rowx.Item1)
{
correlM[rowx.Item1, rowy.Item1] = MathNet.Numerics.Statistics.Correlation.Pearson(rowx.Item2, rowy.Item2);
}
if (rowy.Item1 < rowx.Item1)
{
correlM[rowx.Item1, rowy.Item1] = correlM[rowy.Item1, rowx.Item1];
}
}
}
//Diagonal elements
foreach (var rowx in x.RowEnumerator())
{
correlM[rowx.Item1, rowx.Item1] = MathNet.Numerics.Statistics.Correlation.Pearson(rowx.Item2, rowx.Item2);
}
return correlM;
}