|
Dew Stats for .NET
|
Calculate the variance-covariance matrix (Result), assuming vectors X and Y are two variable and their elements are the observations.
public Covariance(TDenseMtxVec X, TDenseMtxVec Y, TMtx Result, bool NormN);
X and Y can be two vectors or matrices of equal size. In first case two vectors are treated as two variables, X values as first variable observables, Y vector values as second variable observabled. In second case two matrices are treated as two variables X and Y, all X values as X variable observables and all Y values as Y variable observables.
For column-vector valued random variables X and Y with respective expected values mu and nu, and respective scalar components m and n, the covariance is defined to be the m×n matrix called the covariance matrix:
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] } }
|
What do you think about this topic? Send feedback!
|
|
Copyright (c) 1999-2010 by Dew Research. All rights reserved.
|