vectorf vector_a={1,2,3,4,5};
vectorf vector_b={0,1,0.5,2,2.5};
Print("vectors correlation ",vector_a.CorrCoef(vector_b));
//---
matrixf matrix_a={{1,2,3,4,5},
{0,1,0.5,2,2.5}};
Print("matrix rows correlation\n",matrix_a.CorrCoef());
matrixf matrix_a2=matrix_a.Transpose();
Print("transposed matrix cols correlation\n",matrix_a2.CorrCoef(false));
matrixf matrix_a3={{1.0f, 2.0f, 3.0f, 4.0f, 5.0f},
{0.0f, 1.0f, 0.5f, 2.0f, 2.5f},
{0.1f, 1.0f, 2.0f, 1.0f, 0.3f}};
Print("rows correlation\n",matrix_a3.CorrCoef());
Print("cols correlation\n",matrix_a3.CorrCoef(false));
/*
vectors correlation 0.9149913787841797
matrix rows correlation
[[1,0.91499138]
[0.91499138,1]]
transposed matrix cols correlation
[[1,0.91499138]
[0.91499138,1]]
rows correlation
[[1,0.91499138,0.08474271]
[0.91499138,1,-0.17123166]
[0.08474271,-0.17123166,1]]
cols correlation
[[1,0.99587059,0.85375023,0.91129309,0.83773589]
[0.99587059,1,0.80295509,0.94491106,0.88385159]
[0.85375023,0.80295509,1,0.56362146,0.43088508]
[0.91129309,0.94491106,0.56362146,1,0.98827404]
[0.83773589,0.88385159,0.43088508,0.98827404,1]]
*/
|