Logo ROOT   6.08/07
Reference Guide
Go to the documentation of this file.
1 // @(#)root/hist:$Id$
2 // Author: Christian Holm Christensen 1/8/2000
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
12 #ifndef ROOT_TPrincipal
13 #define ROOT_TPrincipal
15 #ifndef ROOT_TNamed
16 #include "TNamed.h"
17 #endif
18 #ifndef ROOT_TVectorD
19 #include "TVectorD.h"
20 #endif
21 #ifndef ROOT_TMatrixD
22 #include "TMatrixD.h"
23 #endif
24 #ifndef ROOT_TList
25 #include "TList.h"
26 #endif
28 class TPrincipal : public TNamed {
30 protected:
31  Int_t fNumberOfDataPoints; // Number of data points
32  Int_t fNumberOfVariables; // Number of variables
34  TVectorD fMeanValues; // Mean value over all data points
35  TVectorD fSigmas; // vector of sigmas
36  TMatrixD fCovarianceMatrix; // Covariance matrix
38  TMatrixD fEigenVectors; // Eigenvector matrix of trans
39  TVectorD fEigenValues; // Eigenvalue vector of trans
41  TVectorD fOffDiagonal; // elements of the tridiagonal
43  TVectorD fUserData; // Vector of original data points
45  Double_t fTrace; // Trace of covarience matrix
47  TList *fHistograms; // List of histograms
49  Bool_t fIsNormalised; // Normalize matrix?
50  Bool_t fStoreData; // Should we store input data?
52  TPrincipal(const TPrincipal&);
55  void MakeNormalised();
56  void MakeRealCode(const char *filename, const char *prefix, Option_t *option="");
58 public:
59  TPrincipal();
60  virtual ~TPrincipal();
61  TPrincipal(Int_t nVariables, Option_t *opt="ND");
63  virtual void AddRow(const Double_t *x);
64  virtual void Browse(TBrowser *b);
65  virtual void Clear(Option_t *option="");
67  const TVectorD *GetEigenValues() const {return &fEigenValues;}
68  const TMatrixD *GetEigenVectors() const {return &fEigenVectors;}
69  TList *GetHistograms() const {return fHistograms;}
70  const TVectorD *GetMeanValues() const {return &fMeanValues;}
71  const Double_t *GetRow(Int_t row);
72  const TVectorD *GetSigmas() const {return &fSigmas;}
73  const TVectorD *GetUserData() const {return &fUserData;}
74  Bool_t IsFolder() const { return kTRUE;}
75  virtual void MakeCode(const char *filename ="pca", Option_t *option=""); // *MENU*
76  virtual void MakeHistograms(const char *name = "pca", Option_t *option="epsdx"); // *MENU*
77  virtual void MakeMethods(const char *classname = "PCA", Option_t *option=""); // *MENU*
78  virtual void MakePrincipals(); // *MENU*
79  virtual void P2X(const Double_t *p, Double_t *x, Int_t nTest);
80  virtual void Print(Option_t *opt="MSE") const; // *MENU*
81  virtual void SumOfSquareResiduals(const Double_t *x, Double_t *s);
82  void Test(Option_t *option=""); // *MENU*
83  virtual void X2P(const Double_t *x, Double_t *p);
85  ClassDef(TPrincipal,2) // Principal Components Analysis
86 }
87 ;
89 #endif
Principal Components Analysis (PCA)
Definition: TPrincipal.h:28
virtual void Browse(TBrowser *b)
Browse the TPrincipal object in the TBrowser.
Definition: TPrincipal.cxx:457
Bool_t fIsNormalised
Definition: TPrincipal.h:49
virtual ~TPrincipal()
Definition: TPrincipal.cxx:357
void MakeRealCode(const char *filename, const char *prefix, Option_t *option="")
This is the method that actually generates the code for the transformations to and from feature space...
Definition: TPrincipal.cxx:884
TMatrixD fEigenVectors
Definition: TPrincipal.h:38
virtual void Print(Option_t *opt="MSE") const
Print the statistics Options are.
TList * fHistograms
Definition: TPrincipal.h:47
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.
const char Option_t
Definition: RtypesCore.h:62
TVectorD fMeanValues
Definition: TPrincipal.h:34
virtual void SumOfSquareResiduals(const Double_t *x, Double_t *s)
Calculates the sum of the square residuals, that is.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void MakeNormalised()
Normalize the covariance matrix.
Definition: TPrincipal.cxx:787
void Test(Option_t *option="")
Test the PCA, bye calculating the sum square of residuals (see method SumOfSquareResiduals), and display the histogram.
Int_t fNumberOfVariables
Definition: TPrincipal.h:32
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
virtual void MakeMethods(const char *classname="PCA", Option_t *option="")
Generate the file <classname>PCA.cxx which contains the implementation of two methods: void <classnam...
Definition: TPrincipal.cxx:849
Double_t fTrace
Definition: TPrincipal.h:45
virtual void MakeHistograms(const char *name="pca", Option_t *option="epsdx")
Make histograms of the result of the analysis.
Definition: TPrincipal.cxx:569
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...
A doubly linked list.
Definition: TList.h:47
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
Definition: TPrincipal.h:74
TVectorD fUserData
Definition: TPrincipal.h:43
virtual void AddRow(const Double_t *x)
Add a data point and update the covariance matrix.
Definition: TPrincipal.cxx:410
TVectorD fEigenValues
Definition: TPrincipal.h:39
const TMatrixD * GetCovarianceMatrix() const
Definition: TPrincipal.h:66
virtual void MakePrincipals()
Perform the principal components analysis.
Definition: TPrincipal.cxx:862
Int_t fNumberOfDataPoints
Definition: TPrincipal.h:31
const TVectorD * GetSigmas() const
Definition: TPrincipal.h:72
virtual void Clear(Option_t *option="")
Clear the data in Object.
Definition: TPrincipal.cxx:480
Bool_t fStoreData
Definition: TPrincipal.h:50
const TVectorD * GetMeanValues() const
Definition: TPrincipal.h:70
const Double_t * GetRow(Int_t row)
Return a row of the user supplied data.
Definition: TPrincipal.cxx:507
double Double_t
Definition: RtypesCore.h:55
TPrincipal & operator=(const TPrincipal &)
Assignment operator.
Definition: TPrincipal.cxx:333
TList * GetHistograms() const
Definition: TPrincipal.h:69
TVectorD fOffDiagonal
Definition: TPrincipal.h:41
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
const TMatrixD * GetEigenVectors() const
Definition: TPrincipal.h:68
virtual void MakeCode(const char *filename="pca", Option_t *option="")
Generates the file <filename>, with .C appended if it does argument doesn&#39;t end in ...
Definition: TPrincipal.cxx:544
const TVectorD * GetUserData() const
Definition: TPrincipal.h:73
const TVectorD * GetEigenValues() const
Definition: TPrincipal.h:67
const Bool_t kTRUE
Definition: Rtypes.h:91
char name[80]
Definition: TGX11.cxx:109
TMatrixD fCovarianceMatrix
Definition: TPrincipal.h:36
TVectorD fSigmas
Definition: TPrincipal.h:35
Empty constructor. Do not use.
Definition: TPrincipal.cxx:229