Scatter matrix and covariance
Covariance is used very often by data scientists to find out how two ordered sets of data follow in the same direction. It can very easily define whether the variables are correlated or not. To best represent this behavior, we create a covariance matrix. The unnormalized version of the covariance matrix is the scatter matrix.
To create a scatter matrix, we use the scattermat(arr)
function.
The default behavior is to treat each row as an observation and column as a variable. This can be changed by providing the keyword arguments vardim
and mean
:
Vardim
:vardim=1 (default)
means each column is a variable and each row is an observation. vardim=2 is the reverse.mean
: The mean is computed byscattermat
. We can use a predefined mean to save compute cycles.
We can also create a weighted covariance matrix using the cov
function. It also takes vardim and mean as optional arguments for the same purpose.