Logo ROOT   6.10/09
Reference Guide
TPrincipal.h
Go to the documentation of this file.
1 // @(#)root/hist:$Id$
2 // Author: Christian Holm Christensen 1/8/2000
3 
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  *************************************************************************/
11 
12 #ifndef ROOT_TPrincipal
13 #define ROOT_TPrincipal
14 
15 #include "TNamed.h"
16 #include "TVectorD.h"
17 #include "TMatrixD.h"
18 #include "TList.h"
19 
20 class TPrincipal : public TNamed {
21 
22 protected:
23  Int_t fNumberOfDataPoints; // Number of data points
24  Int_t fNumberOfVariables; // Number of variables
25 
26  TVectorD fMeanValues; // Mean value over all data points
27  TVectorD fSigmas; // vector of sigmas
28  TMatrixD fCovarianceMatrix; // Covariance matrix
29 
30  TMatrixD fEigenVectors; // Eigenvector matrix of trans
31  TVectorD fEigenValues; // Eigenvalue vector of trans
32 
33  TVectorD fOffDiagonal; // elements of the tridiagonal
34 
35  TVectorD fUserData; // Vector of original data points
36 
37  Double_t fTrace; // Trace of covarience matrix
38 
39  TList *fHistograms; // List of histograms
40 
41  Bool_t fIsNormalised; // Normalize matrix?
42  Bool_t fStoreData; // Should we store input data?
43 
44  TPrincipal(const TPrincipal&);
46 
47  void MakeNormalised();
48  void MakeRealCode(const char *filename, const char *prefix, Option_t *option="");
49 
50 public:
51  TPrincipal();
52  virtual ~TPrincipal();
53  TPrincipal(Int_t nVariables, Option_t *opt="ND");
54 
55  virtual void AddRow(const Double_t *x);
56  virtual void Browse(TBrowser *b);
57  virtual void Clear(Option_t *option="");
59  const TVectorD *GetEigenValues() const {return &fEigenValues;}
60  const TMatrixD *GetEigenVectors() const {return &fEigenVectors;}
61  TList *GetHistograms() const {return fHistograms;}
62  const TVectorD *GetMeanValues() const {return &fMeanValues;}
63  const Double_t *GetRow(Int_t row);
64  const TVectorD *GetSigmas() const {return &fSigmas;}
65  const TVectorD *GetUserData() const {return &fUserData;}
66  Bool_t IsFolder() const { return kTRUE;}
67  virtual void MakeCode(const char *filename ="pca", Option_t *option=""); // *MENU*
68  virtual void MakeHistograms(const char *name = "pca", Option_t *option="epsdx"); // *MENU*
69  virtual void MakeMethods(const char *classname = "PCA", Option_t *option=""); // *MENU*
70  virtual void MakePrincipals(); // *MENU*
71  virtual void P2X(const Double_t *p, Double_t *x, Int_t nTest);
72  virtual void Print(Option_t *opt="MSE") const; // *MENU*
73  virtual void SumOfSquareResiduals(const Double_t *x, Double_t *s);
74  void Test(Option_t *option=""); // *MENU*
75  virtual void X2P(const Double_t *x, Double_t *p);
76 
77  ClassDef(TPrincipal,2) // Principal Components Analysis
78 }
79 ;
80 
81 #endif
Principal Components Analysis (PCA)
Definition: TPrincipal.h:20
virtual void Browse(TBrowser *b)
Browse the TPrincipal object in the TBrowser.
Definition: TPrincipal.cxx:457
Bool_t fIsNormalised
Definition: TPrincipal.h:41
virtual ~TPrincipal()
Destructor.
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:30
virtual void Print(Option_t *opt="MSE") const
Print the statistics Options are.
TList * fHistograms
Definition: TPrincipal.h:39
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:26
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:24
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:297
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
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:37
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:43
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
Definition: TPrincipal.h:66
TVectorD fUserData
Definition: TPrincipal.h:35
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:31
const TMatrixD * GetCovarianceMatrix() const
Definition: TPrincipal.h:58
virtual void MakePrincipals()
Perform the principal components analysis.
Definition: TPrincipal.cxx:862
Int_t fNumberOfDataPoints
Definition: TPrincipal.h:23
const TVectorD * GetSigmas() const
Definition: TPrincipal.h:64
virtual void Clear(Option_t *option="")
Clear the data in Object.
Definition: TPrincipal.cxx:480
Bool_t fStoreData
Definition: TPrincipal.h:42
const TVectorD * GetMeanValues() const
Definition: TPrincipal.h:62
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:61
TVectorD fOffDiagonal
Definition: TPrincipal.h:33
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:60
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:65
const TVectorD * GetEigenValues() const
Definition: TPrincipal.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:91
TMatrixD fCovarianceMatrix
Definition: TPrincipal.h:28
TVectorD fSigmas
Definition: TPrincipal.h:27
TPrincipal()
Empty constructor. Do not use.
Definition: TPrincipal.cxx:229