Covariance

Overview


Covariance


Covariance is similar to the second moment. It is defined
{% cov(X,Y) = \mathbb{E}[(X- \mathbb{E}[X])(Y - \mathbb{E}[Y])] %}



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!

Correlation


{% Corr(X,Y) = \frac{Cov(X,Y)}{\sigma_x \sigma_y} %}



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 correlations = mt.correlations(numbers);
					
Try it!

Contents