Maxima Function
cor (matrix)
cor(matrix,logical_value)
The correlation matrix of the multivariate sample.
Example:
(%i1) load (descriptive)$ (%i2) load (numericalio)$ (%i3) fpprintprec:7$ (%i4) s2 : read_matrix (file_search ("wind.data"))$ (%i5) cor (s2); [ 1.0 .8476339 .8803515 .8239624 .7519506 ] [ ] [ .8476339 1.0 .8735834 .6902622 0.782502 ] [ ] (%o5) [ .8803515 .8735834 1.0 .7764065 .8323358 ] [ ] [ .8239624 .6902622 .7764065 1.0 .7293848 ] [ ] [ .7519506 0.782502 .8323358 .7293848 1.0 ]
Function cor
has an optional logical argument: cor(x,true)
tells Maxima that x
is the data matrix, making the same as cor(x)
. On the other hand, cor(x,false)
means that x
is not the data matrix, but the covariance matrix, avoiding its recalculation,
(%i1) load (descriptive)$ (%i2) load (numericalio)$ (%i3) fpprintprec:7$ (%i4) s2 : read_matrix (file_search ("wind.data"))$ (%i5) s : cov1 (s2)$ (%i6) cor (s, false); /* this is faster */ [ 1.0 .8476339 .8803515 .8239624 .7519506 ] [ ] [ .8476339 1.0 .8735834 .6902622 0.782502 ] [ ] (%o6) [ .8803515 .8735834 1.0 .7764065 .8323358 ] [ ] [ .8239624 .6902622 .7764065 1.0 .7293848 ] [ ] [ .7519506 0.782502 .8323358 .7293848 1.0 ]