Overload List
| # | Signature | Description |
|---|---|---|
| 1 | void PCA(TMtx Data, TMtx PC, TMtx ZScores, TVec EigenVec, TVec VarPct, TPCAMode PCAMode) | Perform a PCA on Data matrix, where Data columns are variables and rows are the observables. |
| 2 | void PCA(TMtx CovMat, TMtx PC, TVec EigenVec, TVec VarPct) | Performs a principal component analysis (PCA). |
Overload 1: void PCA(TMtx Data, TMtx PC, TMtx ZScores, TVec EigenVec, TVec VarPct, TPCAMode PCAMode)
Perform a PCA on Data matrix, where Data columns are variables and rows are the observables.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Data | TMtx | source TMtx |
| 2 | PC | TMtx | source TMtx |
| 3 | ZScores | TMtx | source TMtx |
| 4 | EigenVec | TVec | source TVec |
| 5 | VarPct | TVec | source TVec |
| 6 | PCAMode | TPCAMode |
Result: stored in self (calling object)
The (optional) PCAMode parameter defines whether the analysis should be run on correlation or covariance matrix. PCA procedure returns the principal components in matrix PC, the Z-scores (data, transformed in the PC space) in ZScores, the eigenvalues of the covariance matrix (variances) in the EigenVec vector and (optional) the percentage of total variance in VarPct vector. The PC, ZScores, EigenVec and VarPct dimensions are adjusted automatically.
using Dew.Math;
using Dew.Stat.Units;
namespace Dew.Examples
{
private void Example()
{
Matrix data = new Matrix(0, 0);
Matrix PC = new Matrix(0, 0);
Matrix Z = new Matrix(0, 0);
Vector variances = new Vector(0);
Vector varPercent = new Vector(0);
data.SetIt(2, 4, false, new double[]
{1,3,5,2,
2,5,7,9});
Statistics.PCA(data, PC, Z, variances, varPercent, TPCAMode.PCACovMat); //works on raw data
// ... variances = [29,0,0,0]
// varPercent = [100,0,0,0]
}
}
Overload 2: void PCA(TMtx CovMat, TMtx PC, TVec EigenVec, TVec VarPct)
Performs a principal component analysis (PCA).
| # | Name | Type | Description |
|---|---|---|---|
| 1 | CovMat | TMtx | source TMtx |
| 2 | PC | TMtx | source TMtx |
| 3 | EigenVec | TVec | source TVec |
| 4 | VarPct | TVec | source TVec |
Result: stored in self (calling object)
Perform a PCA by using the original data covariance matrix CovMat. Return the principal components in PC matrix, eigenvalues of the covariance matrix (variances) in vector EigenVec and (optional) the percentage of total variance in vector VarPct. The PC, EigenVec and VarPct dimensions are adjusted automatically.
using Dew.Math;
using Dew.Stats;
using Dew.Stats.Units;
namespace Dew.Examples
{
private void Example
{
Matrix data = new Matrix(0, 0);
Matrix PC = new Matrix(0, 0);
Vector Z = new Vector(0);
Vector variances = new Vector(0);
data.SetIt(2,4, false, new double[] { 1,3,5,2,2,5,7,9});
Statistics.Covariance(data,covMat,false);
Statistics.PCA(covMat, PC, Z, variances); //requires cov matrix
// Z = [29 , 0, 0 ,0 ]
//variance = [100, 0, 0 ,0 ]
}
}