You are here: Symbol Reference > Statistics Namespace > Functions > Statistics.CorrCoef Function
Stats Master VCL
ContentsIndex
Example

Calculate correlation coefficients from Data1 and Data2 representing two variables.

Uses MtxExpr, Statistics;
procedure Example;
var Data1, Data2: Vector;
  CorrMtx : Matrix;
begin
  Data1.SetIt(False,[1,2,3]);
  Data2.SetIt(False,[5,5.5,1]);
  CorrCoef(Data1,Data2,CorrMtx);
  // CorrMtx = [1.00000000, -0.81088485,
  //            -0.81088485,  1.00000000]
end;
#include "MtxExpr.hpp"
#include "Statistics.hpp"
void __fastcall Example()
{
  sVector data1,data2;
  sMatrix corr;
  data1.SetIt(false,OPENARRAY(double,(1,2,3)));
  data2.SetIt(false,OPENARRAY(double,(5,5.5,1.0)));
  CorrCoeff(data1,data2,corr);
  // corr = [1.00000000, -0.81088485,
  //            -0.81088485,  1.00000000]
}
Copyright (c) 1999-2025 by Dew Research. All rights reserved.