MeasuresCorrelation Method (Double, Double, Double) |
Namespace: Accord.Statistics
public static double[,] Correlation( this double[,] matrix, double[] means, double[] standardDeviations )
// Let's say we have a matrix containing 5 // samples (rows) of 3 dimensions (columns): double[,] matrix = new double[,] { { 4.0, 2.0, 0.60 }, { 4.2, 2.1, 0.59 }, { 3.9, 2.0, 0.58 }, { 4.3, 2.1, 0.62 }, { 4.1, 2.2, 0.63 } }; // We can compute their correlation matrix using double[,] corr1 = Measures.Correlation(matrix); // The matrix should be equal to: double[,] expected = new double[,] { { 1.000000, 0.5669467, 0.533745 }, { 0.566946, 1.0000000, 0.778127 }, { 0.533745, 0.7781271, 1.000000 } }; // The same could be repeated with a jagged matrix instead: double[][] jagged = new double[][] { new double[] { 4.0, 2.0, 0.60 }, new double[] { 4.2, 2.1, 0.59 }, new double[] { 3.9, 2.0, 0.58 }, new double[] { 4.3, 2.1, 0.62 }, new double[] { 4.1, 2.2, 0.63 } }; // And the value would be the same: double[][] corr2 = Measures.Correlation(jagged);