ROOT  6.06/09
Reference Guide
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TPrincipal Class Reference

Principal Components Analysis (PCA)

The current implementation is based on the LINTRA package from CERNLIB by R. Brun, H. Hansroul, and J. Kubler. The class has been implemented by Christian Holm Christensen in August 2000.

Introduction

In many applications of various fields of research, the treatment of large amounts of data requires powerful techniques capable of rapid data reduction and analysis. Usually, the quantities most conveniently measured by the experimentalist, are not necessarily the most significant for classification and analysis of the data. It is then useful to have a way of selecting an optimal set of variables necessary for the recognition process and reducing the dimensionality of the problem, resulting in an easier classification procedure.

This paper describes the implementation of one such method of feature selection, namely the principal components analysis. This multidimensional technique is well known in the field of pattern recognition and and its use in Particle Physics has been documented elsewhere (cf. H. Wind, Function Parameterization, CERN 72-21).

Overview

Suppose we have prototypes which are trajectories of particles, passing through a spectrometer. If one measures the passage of the particle at say 8 fixed planes, the trajectory is described by an 8-component vector:

\[ \mathbf{x} = \left(x_0, x_1, \ldots, x_7\right) \]

in 8-dimensional pattern space.

One proceeds by generating a a representative tracks sample and building up the covariance matrix \(\mathsf{C}\). Its eigenvectors and eigenvalues are computed by standard methods, and thus a new basis is obtained for the original 8-dimensional space the expansion of the prototypes,

\[ \mathbf{x}_m = \sum^7_{i=0} a_{m_i} \mathbf{e}_i \quad \mbox{where} \quad a_{m_i} = \mathbf{x}^T\bullet\mathbf{e}_i \]

allows the study of the behavior of the coefficients \(a_{m_i}\) for all the tracks of the sample. The eigenvectors which are insignificant for the trajectory description in the expansion will have their corresponding coefficients \(a_{m_i}\) close to zero for all the prototypes.

On one hand, a reduction of the dimensionality is then obtained by omitting these least significant vectors in the subsequent analysis.

On the other hand, in the analysis of real data, these least significant variables(?) can be used for the pattern recognition problem of extracting the valid combinations of coordinates describing a true trajectory from the set of all possible wrong combinations.

The program described here performs this principal components analysis on a sample of data provided by the user. It computes the covariance matrix, its eigenvalues ands corresponding eigenvectors and exhibits the behavior of the principal components \(a_{m_i}\), thus providing to the user all the means of understanding their data.

Principal Components Method

Let's consider a sample of \(M\) prototypes each being characterized by \(P\) variables \(x_0, x_1, \ldots, x_{P-1}\). Each prototype is a point, or a column vector, in a \(P\)-dimensional Pattern space.

\[ \mathbf{x} = \left[\begin{array}{c} x_0\\x_1\\\vdots\\x_{P-1}\end{array}\right]\,, \]

where each \(x_n\) represents the particular value associated with the \(n\)-dimension.

Those \(P\) variables are the quantities accessible to the experimentalist, but are not necessarily the most significant for the classification purpose.

The Principal Components Method consists of applying a linear* transformation to the original variables. This transformation is described by an orthogonal matrix and is equivalent to a rotation of the original pattern space into a new set of coordinate vectors, which hopefully provide easier feature identification and dimensionality reduction.

Let's define the covariance matrix:

\[ \mathsf{C} = \left\langle\mathbf{y}\mathbf{y}^T\right\rangle \quad\mbox{where}\quad \mathbf{y} = \mathbf{x} - \left\langle\mathbf{x}\right\rangle\,, \]

and the brackets indicate mean value over the sample of \(M\) prototypes.

This matrix \(\mathsf{C}\) is real, positive definite, symmetric, and will have all its eigenvalues greater then zero. It will now be show that among the family of all the complete orthonormal bases of the pattern space, the base formed by the eigenvectors of the covariance matrix and belonging to the largest eigenvalues, corresponds to the most significant features of the description of the original prototypes.

let the prototypes be expanded on into a set of \(N\) basis vectors \(\mathbf{e}_n, n=0,\ldots,N,N+1, \ldots, P-1\)

\[ \mathbf{y}_i = \sum^N_{i=0} a_{i_n} \mathbf{e}_n, \quad i = 1, \ldots, M, \quad N < P-1 \]

The `best' feature coordinates \(\mathbf{e}_n\), spanning a feature space, will be obtained by minimizing the error due to this truncated expansion, i.e.,

\[ \min\left(E_N\right) = \min\left[\left\langle\left(\mathbf{y}_i - \sum^N_{i=0} a_{i_n} \mathbf{e}_n\right)^2\right\rangle\right] \]

with the conditions:

\[ \mathbf{e}_k\bullet\mathbf{e}_j = \delta_{jk} = \left\{\begin{array}{rcl} 1 & \mbox{for} & k = j\\ 0 & \mbox{for} & k \neq j \end{array}\right. \]

Multiplying (3) by \(\mathbf{e}^T_n\) using (5), we get

\[ a_{i_n} = \mathbf{y}_i^T\bullet\mathbf{e}_n\,, \]

so the error becomes

\begin{eqnarray*} E_N &=& \left\langle\left[\sum_{n=N+1}^{P-1} a_{i_n}\mathbf{e}_n\right]^2\right\rangle\nonumber\\ &=& \left\langle\left[\sum_{n=N+1}^{P-1} \mathbf{y}_i^T\bullet\mathbf{e}_n\mathbf{e}_n\right]^2\right\rangle\nonumber\\ &=& \left\langle\sum_{n=N+1}^{P-1} \mathbf{e}_n^T\mathbf{y}_i\mathbf{y}_i^T\mathbf{e}_n\right\rangle\nonumber\\ &=& \sum_{n=N+1}^{P-1} \mathbf{e}_n^T\mathsf{C}\mathbf{e}_n \end{eqnarray*}

The minimization of the sum in (7) is obtained when each term \(\mathbf{e}_n^\mathsf{C}\mathbf{e}_n\) is minimum, since \(\mathsf{C}\) is positive definite. By the method of Lagrange multipliers, and the condition (5), we get

\[ E_N = \sum^{P-1}_{n=N+1} \left(\mathbf{e}_n^T\mathsf{C}\mathbf{e}_n - l_n\mathbf{e}_n^T\bullet\mathbf{e}_n + l_n\right) \]

The minimum condition \(\frac{dE_N}{d\mathbf{e}^T_n} = 0\) leads to the equation

\[ \mathsf{C}\mathbf{e}_n = l_n\mathbf{e}_n\,, \]

which shows that \(\mathbf{e}_n\) is an eigenvector of the covariance matrix \(\mathsf{C}\) with eigenvalue \(l_n\). The estimated minimum error is then given by

\[ E_N \sim \sum^{P-1}_{n=N+1} \mathbf{e}_n^T\bullet l_n\mathbf{e}_n = \sum^{P-1}_{n=N+1} l_n\,, \]

where \(l_n,\,n=N+1,\ldots,P\) \(l_n,\,n=N+1,\ldots,P-1\) are the eigenvalues associated with the omitted eigenvectors in the expansion (3). Thus, by choosing the \(N\) largest eigenvalues, and their associated eigenvectors, the error \(E_N\) is minimized.

The transformation matrix to go from the pattern space to the feature space consists of the ordered eigenvectors \(\mathbf{e}_1,\ldots,\mathbf{e}_P\) \(\mathbf{e}_0,\ldots,\mathbf{e}_{P-1}\) for its columns

\[ \mathsf{T} = \left[ \begin{array}{cccc} \mathbf{e}_0 & \mathbf{e}_1 & \vdots & \mathbf{e}_{P-1} \end{array}\right] = \left[ \begin{array}{cccc} \mathbf{e}_{0_0} & \mathbf{e}_{1_0} & \cdots & \mathbf{e}_{{P-1}_0}\\ \mathbf{e}_{0_1} & \mathbf{e}_{1_1} & \cdots & \mathbf{e}_{{P-1}_1}\\ \vdots & \vdots & \ddots & \vdots \\ \mathbf{e}_{0_{P-1}} & \mathbf{e}_{1_{P-1}} & \cdots & \mathbf{e}_{{P-1}_{P-1}}\\ \end{array}\right] \]

This is an orthogonal transformation, or rotation, of the pattern space and feature selection results in ignoring certain coordinates in the transformed space.

Christian Holm August 2000, CERN

Definition at line 28 of file TPrincipal.h.

Public Member Functions

 TPrincipal ()
 Empty CTOR, Do not use. More...
 
virtual ~TPrincipal ()
 destructor More...
 
 TPrincipal (Int_t nVariables, Option_t *opt="ND")
 Ctor. More...
 
virtual void AddRow (const Double_t *x)
 Begin_Html. More...
 
virtual void Browse (TBrowser *b)
 Browse the TPrincipal object in the TBrowser. More...
 
virtual void Clear (Option_t *option="")
 Clear the data in Object. More...
 
const TMatrixDGetCovarianceMatrix () const
 
const TVectorDGetEigenValues () const
 
const TMatrixDGetEigenVectors () const
 
TListGetHistograms () const
 
const TVectorDGetMeanValues () const
 
const Double_tGetRow (Int_t row)
 Return a row of the user supplied data. More...
 
const TVectorDGetSigmas () const
 
const TVectorDGetUserData () const
 
Bool_t IsFolder () const
 Returns kTRUE in case object contains browsable objects (like containers or lists of other objects). More...
 
virtual void MakeCode (const char *filename="pca", Option_t *option="")
 Generates the file <filename>, with .C appended if it does argument doesn't end in .cxx or .C. More...
 
virtual void MakeHistograms (const char *name="pca", Option_t *option="epsdx")
 Make histograms of the result of the analysis. More...
 
virtual void MakeMethods (const char *classname="PCA", Option_t *option="")
 Generate the file <classname>PCA.cxx which contains the implementation of two methods: More...
 
virtual void MakePrincipals ()
 Perform the principal components analysis. More...
 
virtual void P2X (const Double_t *p, Double_t *x, Int_t nTest)
 Calculate x as a function of nTest of the most significant principal components p, and return it in x. More...
 
virtual void Print (Option_t *opt="MSE") const
 Print the statistics Options are M Print mean values of original data S Print sigma values of original data E Print eigenvalues of covariance matrix V Print eigenvectors of covariance matrix Default is MSE. More...
 
virtual void SumOfSquareResiduals (const Double_t *x, Double_t *s)
 PRIVATE METHOD: Begin_html. More...
 
void Test (Option_t *option="")
 Test the PCA, bye calculating the sum square of residuals (see method SumOfSquareResiduals), and display the histogram. More...
 
virtual void X2P (const Double_t *x, Double_t *p)
 Calculate the principal components from the original data vector x, and return it in p. More...
 
- Public Member Functions inherited from TNamed
 TNamed ()
 
 TNamed (const char *name, const char *title)
 
 TNamed (const TString &name, const TString &title)
 
 TNamed (const TNamed &named)
 
TNamedoperator= (const TNamed &rhs)
 TNamed assignment operator. More...
 
virtual ~TNamed ()
 
virtual TObjectClone (const char *newname="") const
 Make a clone of an object using the Streamer facility. More...
 
virtual Int_t Compare (const TObject *obj) const
 Compare two TNamed objects. More...
 
virtual void Copy (TObject &named) const
 Copy this to obj. More...
 
virtual void FillBuffer (char *&buffer)
 Encode TNamed into output buffer. More...
 
virtual const char * GetName () const
 Returns name of object. More...
 
virtual const char * GetTitle () const
 Returns title of object. More...
 
virtual ULong_t Hash () const
 Return hash value for this object. More...
 
virtual Bool_t IsSortable () const
 
virtual void SetName (const char *name)
 Change (i.e. More...
 
virtual void SetNameTitle (const char *name, const char *title)
 Change (i.e. set) all the TNamed parameters (name and title). More...
 
virtual void SetTitle (const char *title="")
 Change (i.e. set) the title of the TNamed. More...
 
virtual void ls (Option_t *option="") const
 List TNamed name and title. More...
 
virtual Int_t Sizeof () const
 Return size of the TNamed part of the TObject. More...
 
- Public Member Functions inherited from TObject
 TObject ()
 
 TObject (const TObject &object)
 TObject copy ctor. More...
 
TObjectoperator= (const TObject &rhs)
 TObject assignment operator. More...
 
virtual ~TObject ()
 TObject destructor. More...
 
virtual void AppendPad (Option_t *option="")
 Append graphics object to current pad. More...
 
virtual const char * ClassName () const
 Returns name of class to which the object belongs. More...
 
virtual void Delete (Option_t *option="")
 Delete this object. More...
 
virtual Int_t DistancetoPrimitive (Int_t px, Int_t py)
 Computes distance from point (px,py) to the object. More...
 
virtual void Draw (Option_t *option="")
 Default Draw method for all objects. More...
 
virtual void DrawClass () const
 Draw class inheritance tree of the class to which this object belongs. More...
 
virtual TObjectDrawClone (Option_t *option="") const
 Draw a clone of this object in the current pad. More...
 
virtual void Dump () const
 Dump contents of object on stdout. More...
 
virtual void Execute (const char *method, const char *params, Int_t *error=0)
 Execute method on this object with the given parameter string, e.g. More...
 
virtual void Execute (TMethod *method, TObjArray *params, Int_t *error=0)
 Execute method on this object with parameters stored in the TObjArray. More...
 
virtual void ExecuteEvent (Int_t event, Int_t px, Int_t py)
 Execute action corresponding to an event at (px,py). More...
 
virtual TObjectFindObject (const char *name) const
 Must be redefined in derived classes. More...
 
virtual TObjectFindObject (const TObject *obj) const
 Must be redefined in derived classes. More...
 
virtual Option_tGetDrawOption () const
 Get option used by the graphics system to draw this object. More...
 
virtual UInt_t GetUniqueID () const
 Return the unique object id. More...
 
virtual const char * GetIconName () const
 Returns mime type name of object. More...
 
virtual Option_tGetOption () const
 
virtual char * GetObjectInfo (Int_t px, Int_t py) const
 Returns string containing info about the object at position (px,py). More...
 
virtual Bool_t HandleTimer (TTimer *timer)
 Execute action in response of a timer timing out. More...
 
virtual Bool_t InheritsFrom (const char *classname) const
 Returns kTRUE if object inherits from class "classname". More...
 
virtual Bool_t InheritsFrom (const TClass *cl) const
 Returns kTRUE if object inherits from TClass cl. More...
 
virtual void Inspect () const
 Dump contents of this object in a graphics canvas. More...
 
virtual Bool_t IsEqual (const TObject *obj) const
 Default equal comparison (objects are equal if they have the same address in memory). More...
 
Bool_t IsOnHeap () const
 
Bool_t IsZombie () const
 
virtual Bool_t Notify ()
 This method must be overridden to handle object notification. More...
 
virtual void Paint (Option_t *option="")
 This method must be overridden if a class wants to paint itself. More...
 
virtual void Pop ()
 Pop on object drawn in a pad to the top of the display list. More...
 
virtual Int_t Read (const char *name)
 Read contents of object with specified name from the current directory. More...
 
virtual void RecursiveRemove (TObject *obj)
 Recursively remove this object from a list. More...
 
virtual void SaveAs (const char *filename="", Option_t *option="") const
 Save this object in the file specified by filename. More...
 
virtual void SavePrimitive (std::ostream &out, Option_t *option="")
 Save a primitive as a C++ statement(s) on output stream "out". More...
 
virtual void SetDrawOption (Option_t *option="")
 Set drawing option for object. More...
 
virtual void SetUniqueID (UInt_t uid)
 Set the unique object id. More...
 
virtual void UseCurrentStyle ()
 Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked. More...
 
virtual Int_t Write (const char *name=0, Int_t option=0, Int_t bufsize=0)
 Write this object to the current directory. More...
 
virtual Int_t Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const
 Write this object to the current directory. More...
 
voidoperator new (size_t sz)
 
voidoperator new[] (size_t sz)
 
voidoperator new (size_t sz, void *vp)
 
voidoperator new[] (size_t sz, void *vp)
 
void operator delete (void *ptr)
 Operator delete. More...
 
void operator delete[] (void *ptr)
 Operator delete []. More...
 
void SetBit (UInt_t f, Bool_t set)
 Set or unset the user status bits as specified in f. More...
 
void SetBit (UInt_t f)
 
void ResetBit (UInt_t f)
 
Bool_t TestBit (UInt_t f) const
 
Int_t TestBits (UInt_t f) const
 
void InvertBit (UInt_t f)
 
virtual void Info (const char *method, const char *msgfmt,...) const
 Issue info message. More...
 
virtual void Warning (const char *method, const char *msgfmt,...) const
 Issue warning message. More...
 
virtual void Error (const char *method, const char *msgfmt,...) const
 Issue error message. More...
 
virtual void SysError (const char *method, const char *msgfmt,...) const
 Issue system error message. More...
 
virtual void Fatal (const char *method, const char *msgfmt,...) const
 Issue fatal error message. More...
 
void AbstractMethod (const char *method) const
 Use this method to implement an "abstract" method that you don't want to leave purely abstract. More...
 
void MayNotUse (const char *method) const
 Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary). More...
 
void Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const
 Use this method to declare a method obsolete. More...
 

Protected Member Functions

 TPrincipal (const TPrincipal &)
 copy constructor More...
 
TPrincipaloperator= (const TPrincipal &)
 assignement operator More...
 
void MakeNormalised ()
 PRIVATE METHOD: Normalize the covariance matrix. More...
 
void MakeRealCode (const char *filename, const char *prefix, Option_t *option="")
 PRIVATE METHOD: This is the method that actually generates the code for the transformations to and from feature space and pattern space It's called by TPrincipal::MakeCode and TPrincipal::MakeMethods. More...
 
- Protected Member Functions inherited from TObject
void MakeZombie ()
 
virtual void DoError (int level, const char *location, const char *fmt, va_list va) const
 Interface to ErrorHandler (protected). More...
 

Protected Attributes

Int_t fNumberOfDataPoints
 
Int_t fNumberOfVariables
 
TVectorD fMeanValues
 
TVectorD fSigmas
 
TMatrixD fCovarianceMatrix
 
TMatrixD fEigenVectors
 
TVectorD fEigenValues
 
TVectorD fOffDiagonal
 
TVectorD fUserData
 
Double_t fTrace
 
TListfHistograms
 
Bool_t fIsNormalised
 
Bool_t fStoreData
 
- Protected Attributes inherited from TNamed
TString fName
 
TString fTitle
 

Additional Inherited Members

- Public Types inherited from TObject
enum  EStatusBits {
  kCanDelete = BIT(0), kMustCleanup = BIT(3), kObjInCanvas = BIT(3), kIsReferenced = BIT(4),
  kHasUUID = BIT(5), kCannotPick = BIT(6), kNoContextMenu = BIT(8), kInvalidObject = BIT(13)
}
 
enum  { kIsOnHeap = 0x01000000, kNotDeleted = 0x02000000, kZombie = 0x04000000, kBitMask = 0x00ffffff }
 
enum  { kSingleKey = BIT(0), kOverwrite = BIT(1), kWriteDelete = BIT(2) }
 
- Static Public Member Functions inherited from TObject
static Long_t GetDtorOnly ()
 Return destructor only flag. More...
 
static void SetDtorOnly (void *obj)
 Set destructor only flag. More...
 
static Bool_t GetObjectStat ()
 Get status of object stat flag. More...
 
static void SetObjectStat (Bool_t stat)
 Turn on/off tracking of objects in the TObjectTable. More...
 

#include <TPrincipal.h>

+ Inheritance diagram for TPrincipal:
+ Collaboration diagram for TPrincipal:

Constructor & Destructor Documentation

TPrincipal::TPrincipal ( const TPrincipal pr)
protected

copy constructor

Definition at line 316 of file TPrincipal.cxx.

TPrincipal::TPrincipal ( )

Empty CTOR, Do not use.

Definition at line 233 of file TPrincipal.cxx.

TPrincipal::~TPrincipal ( )
virtual

destructor

Definition at line 361 of file TPrincipal.cxx.

TPrincipal::TPrincipal ( Int_t  nVariables,
Option_t opt = "ND" 
)

Ctor.

Argument is number of variables in the sample of data Options are: N Normalize the covariance matrix (default) D Store input data (default)

The created object is named "principal" by default.

Definition at line 257 of file TPrincipal.cxx.

Member Function Documentation

void TPrincipal::AddRow ( const Double_t x)
virtual

Begin_Html.

Definition at line 372 of file TPrincipal.cxx.

Referenced by TMVA::Factory::EvaluateAllMethods(), and TTreePlayer::Principal().

void TPrincipal::Browse ( TBrowser b)
virtual

Browse the TPrincipal object in the TBrowser.

Reimplemented from TObject.

Definition at line 545 of file TPrincipal.cxx.

void TPrincipal::Clear ( Option_t opt = "")
virtual

Clear the data in Object.

Notice, that's not possible to change the dimension of the original data.

Reimplemented from TNamed.

Definition at line 568 of file TPrincipal.cxx.

const TMatrixD* TPrincipal::GetCovarianceMatrix ( ) const
inline

Definition at line 66 of file TPrincipal.h.

Referenced by TMVA::Factory::EvaluateAllMethods().

const TVectorD* TPrincipal::GetEigenValues ( ) const
inline

Definition at line 67 of file TPrincipal.h.

const TMatrixD* TPrincipal::GetEigenVectors ( ) const
inline

Definition at line 68 of file TPrincipal.h.

TList* TPrincipal::GetHistograms ( ) const
inline

Definition at line 69 of file TPrincipal.h.

const TVectorD* TPrincipal::GetMeanValues ( ) const
inline

Definition at line 70 of file TPrincipal.h.

const Double_t * TPrincipal::GetRow ( Int_t  row)

Return a row of the user supplied data.

If row is out of bounds, 0 is returned. It's up to the user to delete the returned array. Row 0 is the first row;

Definition at line 595 of file TPrincipal.cxx.

Referenced by MakeHistograms().

const TVectorD* TPrincipal::GetSigmas ( ) const
inline

Definition at line 72 of file TPrincipal.h.

const TVectorD* TPrincipal::GetUserData ( ) const
inline

Definition at line 73 of file TPrincipal.h.

Bool_t TPrincipal::IsFolder ( ) const
inlinevirtual

Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).

Reimplemented from TObject.

Definition at line 74 of file TPrincipal.h.

void TPrincipal::MakeCode ( const char *  filename = "pca",
Option_t opt = "" 
)
virtual

Generates the file <filename>, with .C appended if it does argument doesn't end in .cxx or .C.

The file contains the implementation of two functions

void X2P(Double_t *x, Double *p) void P2X(Double_t *p, Double *x, Int_t nTest)

which does the same as TPrincipal::X2P and TPrincipal::P2X respectively. Please refer to these methods.

Further, the static variables:

Int_t gNVariables Double_t gEigenValues[] Double_t gEigenVectors[] Double_t gMeanValues[] Double_t gSigmaValues[]

are initialized. The only ROOT header file needed is Rtypes.h

See TPrincipal::MakeRealCode for a list of options

Definition at line 632 of file TPrincipal.cxx.

Referenced by TTreePlayer::Principal().

void TPrincipal::MakeHistograms ( const char *  name = "pca",
Option_t opt = "epsdx" 
)
virtual

Make histograms of the result of the analysis.

The option string say which histograms to create X Histogram original data P Histogram principal components corresponding to original data D Histogram the difference between the original data and the projection of principal unto a lower dimensional subspace (2D histograms) E Histogram the eigenvalues S Histogram the square of the residues (see TPrincipal::SumOfSquareResidues) The histograms will be named <name>_<type><number>, where <name> is the first argument, <type> is one of X,P,D,E,S, and <number> is the variable.

Definition at line 657 of file TPrincipal.cxx.

Referenced by TTreePlayer::Principal(), and Test().

void TPrincipal::MakeMethods ( const char *  classname = "PCA",
Option_t opt = "" 
)
virtual

Generate the file <classname>PCA.cxx which contains the implementation of two methods:

void <classname>::X2P(Double_t *x, Double *p) void <classname>::P2X(Double_t *p, Double *x, Int_t nTest)

which does the same as TPrincipal::X2P and TPrincipal::P2X respectivly. Please refer to these methods.

Further, the public static members:

Int_t <classname>::fgNVariables Double_t <classname>::fgEigenValues[] Double_t <classname>::fgEigenVectors[] Double_t <classname>::fgMeanValues[] Double_t <classname>::fgSigmaValues[]

are initialized, and assumed to exist. The class declaration is assumed to be in <classname>.h and assumed to be provided by the user.

See TPrincipal::MakeRealCode for a list of options

The minimal class definition is:

class <classname> { public: static Int_t fgNVariables; static Double_t fgEigenVectors[]; static Double_t fgEigenValues[]; static Double_t fgMeanValues[]; static Double_t fgSigmaValues[];

void X2P(Double_t *x, Double_t *p); void P2X(Double_t *p, Double_t *x, Int_t nTest); };

Whether the methods <classname>::X2P and <classname>::P2X should be static or not, is up to the user.

Definition at line 937 of file TPrincipal.cxx.

void TPrincipal::MakeNormalised ( )
protected

PRIVATE METHOD: Normalize the covariance matrix.

Definition at line 875 of file TPrincipal.cxx.

Referenced by MakePrincipals().

void TPrincipal::MakePrincipals ( )
virtual

Perform the principal components analysis.

This is done in several stages in the TMatrix::EigenVectors method:

  • Transform the covariance matrix into a tridiagonal matrix.
  • Find the eigenvalues and vectors of the tridiagonal matrix.

Definition at line 950 of file TPrincipal.cxx.

Referenced by TMVA::Factory::EvaluateAllMethods(), and TTreePlayer::Principal().

void TPrincipal::MakeRealCode ( const char *  filename,
const char *  classname,
Option_t option = "" 
)
protected

PRIVATE METHOD: This is the method that actually generates the code for the transformations to and from feature space and pattern space It's called by TPrincipal::MakeCode and TPrincipal::MakeMethods.

The options are: NONE so far

Definition at line 973 of file TPrincipal.cxx.

Referenced by MakeCode(), and MakeMethods().

TPrincipal & TPrincipal::operator= ( const TPrincipal pr)
protected

assignement operator

Definition at line 337 of file TPrincipal.cxx.

void TPrincipal::P2X ( const Double_t p,
Double_t x,
Int_t  nTest 
)
virtual

Calculate x as a function of nTest of the most significant principal components p, and return it in x.

It's the users responsibility to make sure that both x and p are of the right size (i.e., memory must be allocated for x).

Definition at line 1142 of file TPrincipal.cxx.

Referenced by MakeHistograms(), and SumOfSquareResiduals().

void TPrincipal::Print ( Option_t opt = "MSE") const
virtual

Print the statistics Options are M Print mean values of original data S Print sigma values of original data E Print eigenvalues of covariance matrix V Print eigenvectors of covariance matrix Default is MSE.

Reimplemented from TNamed.

Definition at line 1162 of file TPrincipal.cxx.

Referenced by TTreePlayer::Principal().

void TPrincipal::SumOfSquareResiduals ( const Double_t x,
Double_t s 
)
virtual

PRIVATE METHOD: Begin_html.

Definition at line 1243 of file TPrincipal.cxx.

void TPrincipal::Test ( Option_t option = "")

Test the PCA, bye calculating the sum square of residuals (see method SumOfSquareResiduals), and display the histogram.

Definition at line 1313 of file TPrincipal.cxx.

void TPrincipal::X2P ( const Double_t x,
Double_t p 
)
virtual

Calculate the principal components from the original data vector x, and return it in p.

It's the users responsibility to make sure that both x and p are of the right size (i.e., memory must be allocated for p).

Definition at line 1336 of file TPrincipal.cxx.

Referenced by MakeHistograms(), and SumOfSquareResiduals().

Member Data Documentation

TMatrixD TPrincipal::fCovarianceMatrix
protected
TVectorD TPrincipal::fEigenValues
protected
TMatrixD TPrincipal::fEigenVectors
protected
TList* TPrincipal::fHistograms
protected
Bool_t TPrincipal::fIsNormalised
protected

Definition at line 49 of file TPrincipal.h.

Referenced by MakeHistograms(), MakeNormalised(), MakeRealCode(), operator=(), P2X(), TPrincipal(), and X2P().

TVectorD TPrincipal::fMeanValues
protected
Int_t TPrincipal::fNumberOfDataPoints
protected

Definition at line 31 of file TPrincipal.h.

Referenced by AddRow(), Clear(), GetRow(), MakeHistograms(), operator=(), and TPrincipal().

Int_t TPrincipal::fNumberOfVariables
protected
TVectorD TPrincipal::fOffDiagonal
protected

Definition at line 41 of file TPrincipal.h.

Referenced by Clear(), operator=(), and TPrincipal().

TVectorD TPrincipal::fSigmas
protected
Bool_t TPrincipal::fStoreData
protected

Definition at line 50 of file TPrincipal.h.

Referenced by AddRow(), Browse(), Clear(), GetRow(), MakeHistograms(), operator=(), Test(), and TPrincipal().

Double_t TPrincipal::fTrace
protected

Definition at line 45 of file TPrincipal.h.

Referenced by Clear(), MakeHistograms(), MakeNormalised(), operator=(), and TPrincipal().

TVectorD TPrincipal::fUserData
protected

Definition at line 43 of file TPrincipal.h.

Referenced by AddRow(), Browse(), Clear(), GetRow(), GetUserData(), operator=(), and TPrincipal().


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