Obtaining the covariance matrix from samples

A covariance matrix is a symmetric square matrix whose elements in row i and column j correspond to how related they are. More specifically, each element is the covariance of the variables represented by its row and column. Variables that move together in the same direction have a positive covariance, and variables with the opposite behavior have a negative covariance.

Let's assume we are given four sets of data of three variables as shown in the following table:

Obtaining the covariance matrix from samples

Notice how Feature 1 and Feature 3 appear to be similar in their patterns, yet Feature 1 and Feature 2 appear to be uncorrelated. Similarly, ...

Get Haskell Data Analysis Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.