Overview
Covariance is similar to the variance. It is defined
{% cov(X,Y) = \mathbb{E}[(X- \mathbb{E}[X])(Y - \mathbb{E}[Y])] %}
It is a measure of how two
random variables
are related. If
they are
independent,
covariance will be zero.
Topics
- Correlation - a normalized version of the covariance
- Vector Covariance - states the covariance in matrix format
- Diagonalization
Implementation
let mt = await import('/lib/statistics/moments/v1.0.0/moments.mjs');
let numbers = [
[1,2],
[2,2],
[3,6],
[1,3],
[4,4],
];
let covariance = mt.covariance(numbers);
Try it!
let mt = await import('/lib/statistics/moments/v1.0.0/moments.mjs');
let numbers = [
{first:1,second:2},
{first:2,second:2},
{first:3,second:6},
{first:1,second:3},
{first:4,second:4},
];
let covariance = mt.covariance(numbers);
Try it!