Overload List
| # | Signature | Description |
|---|---|---|
| 1 | procedure CorrCoef(const X: TDenseMtxVec; const Y: TDenseMtxVec; const aResult: TMtx); | Pearson correlation coefficients. |
| 2 | procedure CorrCoef(const X: TDenseMtxVec; const Y: TDenseMtxVec; const aResult: TMtx; var tValue: Double); | Pearson correlation coefficients. |
| 3 | procedure CorrCoef(const X: TMtx; const aResult: TMtx); | Pearson correlation coefficients between matrix rows and cols. |
Overload 1: procedure CorrCoef(const X: TDenseMtxVec; const Y: TDenseMtxVec; const aResult: TMtx);
Pearson correlation coefficients.
| # | Name | Description |
|---|---|---|
| 1 | X | Defines first sample (variable) values (observables). |
| 2 | Y | Defines second sample (variable) values (observables). |
| 3 | aResult | Returns Pearson correlation coefficients bewteen samples X and Y. Size of Result is adjusted automatically. |
Result: stored in self (calling object)
Correlation coefficient
The correlation coefficient rho between two random variables is defined by the following equation:
where x,y are two variables, Cov covariance betwen x and y, sigma(s) their expected standard deviations and E-s their expected values. If the variables are independent then the correlation is 0, but the converse is not true because the correlation coefficient detects only linear dependencies between two variables.
Sample correlation coefficients.
If we have a series of n measurements of X and Y, then the Pearson product-moment correlation coefficient can be used to estimate the correlation of X and Y. The Pearson coefficient is also known as the "sample correlation coefficient". The Pearson correlation coefficient is then the best estimate of the correlation of X and Y .
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;
Overload 2: procedure CorrCoef(const X: TDenseMtxVec; const Y: TDenseMtxVec; const aResult: TMtx; var tValue: Double);
Pearson correlation coefficients.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | X | TDenseMtxVec | |
| 2 | Y | TDenseMtxVec | |
| 3 | aResult | TMtx | |
| 4 | tValue | Double |
Result: stored in self (calling object)
Additionally returns also the Students t-distribution value as an indicator of statistical significance.
Overload 3: procedure CorrCoef(const X: TMtx; const aResult: TMtx);
Pearson correlation coefficients between matrix rows and cols.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | X | TMtx | |
| 2 | aResult | TMtx |
Result: stored in self (calling object)
This version calculates Pearson correlation coefficients rx,y between X matrix rows and cols. X colums are treated as samples (variables) and rows as values (observables).