You are here: Symbol Reference > Dew.Stats Namespace > Statistics Class > Statistics Methods > Covariance Method > Covariance Method (TDenseMtxVec, TDenseMtxVec, TMtx, boolean)
Dew Stats for .NET
Contents
C# Example

Calculate the covariance matrix from two vectors representing two variables.

using Dew.Math;
using Dew.Stats.Units;
namespace Dew.Examples
{
  private void Example()
  {
    Vector data1 = new Vector(0);
    Vector data2 = new Vector(0);
    Matrix cov = new Matrix(0,0);
    data1.SetIt(false,new double[] {1,2,3});
    data2.SetIt(false,new double[] {5,5.5});
    Statistics.Covariance(data1,data2,cov,false);
    // cov = [1.00000000, -2.00000000,
    //          -2.00000000, 6.083333334]
  }
}
Copyright (c) 1999-2010 by Dew Research. All rights reserved.