Covariance

Author

Eric W. Weisstein
May 2, 2006

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Statistics/Covariance.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/Covariance.html.

©2006 Wolfram Research, Inc. except for portions noted otherwise

Numeric Examples

Uniform

Table[With[{n=10^4},
X=Table[Random[],{n}];
Y=Table[Random[],{n}];
((Total[(X-Mean[X])(Y-Mean[Y])])/n)
],{20}]

Table[With[{n=10^4},
X=RandomArray[UniformDistribution[0,1],n];
Y=RandomArray[UniformDistribution[-2,3],n];
((Total[(X-Mean[X])(Y-Mean[Y])])/n)
],{20}]

Normal

<<Statistics`ContinuousDistributions`

Table[With[{n=10^4},
X=RandomArray[NormalDistribution[1,1],n];
Y=RandomArray[NormalDistribution[1,1],n];
((Total[(X-Mean[X])(Y-Mean[Y])])/n)
],{20}]