OpenWalnut  1.5.0dev
Public Member Functions | Private Member Functions | Private Attributes | List of all members
WPrincipalComponentAnalysis Class Reference

This is a class that analyzes the point distribution of point couds using the Principal Component Analysis. More...

#include <WPrincipalComponentAnalysis.h>

+ Collaboration diagram for WPrincipalComponentAnalysis:

Public Member Functions

 WPrincipalComponentAnalysis ()
 Creates the Principal Component Analysis instance. More...
 
virtual ~WPrincipalComponentAnalysis ()
 Destroys the Principal Component Analysis instance. More...
 
void analyzeData (const vector< WPosition > &inputData)
 Analyzes a point data set using the Principal Component Analysis algorithm. More...
 
WPosition getMean ()
 Returns the mean coordinate of all input points. More...
 
vector< WVector3dgetEigenVectors ()
 Returns the point distribution directions. More...
 
vector< double > getEigenValues ()
 Returns Eigen Values (equals how much the directions of getDirections() are distributed). More...
 

Private Member Functions

void extractEigenData ()
 Does the actual Eigen Value and Vector Analysis. More...
 
void sortByVarianceDescending ()
 Sorts the Point distribution direction by the descending strength. More...
 
void swapEigenVectors (size_t eigenVectorIndex1, size_t eigenVectorIndex2)
 Replaces two Eigen Vectors and its Variances by each other. More...
 

Private Attributes

size_t m_inputPointCount
 Point count of the input data. More...
 
size_t m_dimensions
 Dimension count used in the input data. More...
 
WCovarianceSolver m_covarianceSolver
 Instance to analyze the covariances of the point data between each dimension pair. More...
 
vector< WVector3dm_eigenVectors
 Main point distribution directions. More...
 
vector< double > m_eigenValues
 Lambda values for A*x-Lambda*x=0. More...
 
EigenSolver< MatrixXd > m_eigenSolver
 Instance for solving Eigen Values and Vectors. More...
 
bool m_isValidPCA
 Indicator whether calculation is still valid. More...
 

Detailed Description

This is a class that analyzes the point distribution of point couds using the Principal Component Analysis.

This class puts out vectors of main point distribution directions and how much they are distributed in that directions.

The algorithms are based mainly on Covariance calculation and Eigen Value and Vector analysis. General about Principal Component Analysis: http://georgemdallas.wordpress.com/2013/10/30/principal-component- analysis-4-dummies-eigenvectors-eigenvalues-and-dimension-reduction/ See principle of algorithm here: http://www.cs.otago.ac.nz/cosc453/student_tutorials/principal_components.pdf

Definition at line 54 of file WPrincipalComponentAnalysis.h.

Constructor & Destructor Documentation

◆ WPrincipalComponentAnalysis()

WPrincipalComponentAnalysis::WPrincipalComponentAnalysis ( )

Creates the Principal Component Analysis instance.

Definition at line 28 of file WPrincipalComponentAnalysis.cpp.

References m_isValidPCA.

◆ ~WPrincipalComponentAnalysis()

WPrincipalComponentAnalysis::~WPrincipalComponentAnalysis ( )
virtual

Destroys the Principal Component Analysis instance.

Definition at line 33 of file WPrincipalComponentAnalysis.cpp.

Member Function Documentation

◆ analyzeData()

void WPrincipalComponentAnalysis::analyzeData ( const vector< WPosition > &  inputData)

Analyzes a point data set using the Principal Component Analysis algorithm.

Parameters
inputDataPoint data to be analyzed.

Definition at line 37 of file WPrincipalComponentAnalysis.cpp.

References WCovarianceSolver::analyzeData(), extractEigenData(), WCovarianceSolver::getCovariance(), m_covarianceSolver, m_dimensions, m_eigenSolver, m_inputPointCount, m_isValidPCA, and sortByVarianceDescending().

+ Here is the call graph for this function:

◆ extractEigenData()

void WPrincipalComponentAnalysis::extractEigenData ( )
private

Does the actual Eigen Value and Vector Analysis.

Definition at line 49 of file WPrincipalComponentAnalysis.cpp.

References m_eigenSolver, m_eigenValues, m_eigenVectors, m_isValidPCA, WMatrixFixed< ValueT, Rows, Cols, ValueStoreT >::size(), and sortByVarianceDescending().

Referenced by analyzeData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEigenValues()

vector< double > WPrincipalComponentAnalysis::getEigenValues ( )

Returns Eigen Values (equals how much the directions of getDirections() are distributed).

Its index corresponds to the indices of that method. The strengths are sorted descending.

Returns
Distribution strength in a direction.

Definition at line 103 of file WPrincipalComponentAnalysis.cpp.

References m_eigenValues.

◆ getEigenVectors()

vector< WVector3d > WPrincipalComponentAnalysis::getEigenVectors ( )

Returns the point distribution directions.

The first one is the strongest and the last is the weakest point distribution direction. Their index corresponds to getVariance().

Returns
Point distribution directions.

Definition at line 99 of file WPrincipalComponentAnalysis.cpp.

References m_eigenVectors.

◆ getMean()

WPosition WPrincipalComponentAnalysis::getMean ( )

Returns the mean coordinate of all input points.

Returns
The mean coordinate of all input points.

Definition at line 95 of file WPrincipalComponentAnalysis.cpp.

References WCovarianceSolver::getMean(), and m_covarianceSolver.

+ Here is the call graph for this function:

◆ sortByVarianceDescending()

void WPrincipalComponentAnalysis::sortByVarianceDescending ( )
private

Sorts the Point distribution direction by the descending strength.

Definition at line 75 of file WPrincipalComponentAnalysis.cpp.

References m_dimensions, m_eigenValues, m_inputPointCount, and swapEigenVectors().

Referenced by analyzeData(), and extractEigenData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ swapEigenVectors()

void WPrincipalComponentAnalysis::swapEigenVectors ( size_t  eigenVectorIndex1,
size_t  eigenVectorIndex2 
)
private

Replaces two Eigen Vectors and its Variances by each other.

Parameters
eigenVectorIndex1Index of the first Eigen Value and Vector
eigenVectorIndex2Index of the second Eigen Value and Vector

Definition at line 83 of file WPrincipalComponentAnalysis.cpp.

References m_eigenValues, and m_eigenVectors.

Referenced by sortByVarianceDescending().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_covarianceSolver

WCovarianceSolver WPrincipalComponentAnalysis::m_covarianceSolver
private

Instance to analyze the covariances of the point data between each dimension pair.

Definition at line 118 of file WPrincipalComponentAnalysis.h.

Referenced by analyzeData(), and getMean().

◆ m_dimensions

size_t WPrincipalComponentAnalysis::m_dimensions
private

Dimension count used in the input data.

Definition at line 113 of file WPrincipalComponentAnalysis.h.

Referenced by analyzeData(), and sortByVarianceDescending().

◆ m_eigenSolver

EigenSolver<MatrixXd> WPrincipalComponentAnalysis::m_eigenSolver
private

Instance for solving Eigen Values and Vectors.

Definition at line 130 of file WPrincipalComponentAnalysis.h.

Referenced by analyzeData(), and extractEigenData().

◆ m_eigenValues

vector<double> WPrincipalComponentAnalysis::m_eigenValues
private

Lambda values for A*x-Lambda*x=0.

Definition at line 126 of file WPrincipalComponentAnalysis.h.

Referenced by extractEigenData(), getEigenValues(), sortByVarianceDescending(), and swapEigenVectors().

◆ m_eigenVectors

vector<WVector3d> WPrincipalComponentAnalysis::m_eigenVectors
private

Main point distribution directions.

After process they're sorted by their strength descending.

Definition at line 122 of file WPrincipalComponentAnalysis.h.

Referenced by extractEigenData(), getEigenVectors(), and swapEigenVectors().

◆ m_inputPointCount

size_t WPrincipalComponentAnalysis::m_inputPointCount
private

Point count of the input data.

Definition at line 109 of file WPrincipalComponentAnalysis.h.

Referenced by analyzeData(), and sortByVarianceDescending().

◆ m_isValidPCA

bool WPrincipalComponentAnalysis::m_isValidPCA
private

Indicator whether calculation is still valid.

Definition at line 134 of file WPrincipalComponentAnalysis.h.

Referenced by analyzeData(), extractEigenData(), and WPrincipalComponentAnalysis().


The documentation for this class was generated from the following files: