ROOT  6.06/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 #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
27 
28 class TPrincipal : public TNamed {
29 
30 protected:
31  Int_t fNumberOfDataPoints; // Number of data points
32  Int_t fNumberOfVariables; // Number of variables
33 
34  TVectorD fMeanValues; // Mean value over all data points
35  TVectorD fSigmas; // vector of sigmas
36  TMatrixD fCovarianceMatrix; // Covariance matrix
37 
38  TMatrixD fEigenVectors; // Eigenvector matrix of trans
39  TVectorD fEigenValues; // Eigenvalue vector of trans
40 
41  TVectorD fOffDiagonal; // elements of the tridiagonal
42 
43  TVectorD fUserData; // Vector of original data points
44 
45  Double_t fTrace; // Trace of covarience matrix
46 
47  TList *fHistograms; // List of histograms
48 
49  Bool_t fIsNormalised; // Normalize matrix?
50  Bool_t fStoreData; // Should we store input data?
51 
52  TPrincipal(const TPrincipal&);
54 
55  void MakeNormalised();
56  void MakeRealCode(const char *filename, const char *prefix, Option_t *option="");
57 
58 public:
59  TPrincipal();
60  virtual ~TPrincipal();
61  TPrincipal(Int_t nVariables, Option_t *opt="ND");
62 
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);
84 
85  ClassDef(TPrincipal,2) // Principal Components Analysis
86 }
87 ;
88 
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:545
Bool_t fIsNormalised
Definition: TPrincipal.h:49
const TVectorD * GetEigenValues() const
Definition: TPrincipal.h:67
virtual ~TPrincipal()
destructor
Definition: TPrincipal.cxx:361
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 fr...
Definition: TPrincipal.cxx:973
TMatrixD fEigenVectors
Definition: TPrincipal.h:38
const TVectorD * GetMeanValues() const
Definition: TPrincipal.h:70
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
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 origina...
const TVectorD * GetUserData() const
Definition: TPrincipal.h:73
TVectorD fMeanValues
Definition: TPrincipal.h:34
static const char * filename()
virtual void SumOfSquareResiduals(const Double_t *x, Double_t *s)
PRIVATE METHOD: Begin_html.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void MakeNormalised()
PRIVATE METHOD: Normalize the covariance matrix.
Definition: TPrincipal.cxx:875
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
const TMatrixD * GetEigenVectors() const
Definition: TPrincipal.h:68
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 PCA.cxx which contains the implementation of two methods: ...
Definition: TPrincipal.cxx:937
TList * GetHistograms() const
Definition: TPrincipal.h:69
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:657
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
const TMatrixD * GetCovarianceMatrix() const
Definition: TPrincipal.h:66
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
TVectorD fUserData
Definition: TPrincipal.h:43
virtual void AddRow(const Double_t *x)
Begin_Html.
Definition: TPrincipal.cxx:372
TVectorD fEigenValues
Definition: TPrincipal.h:39
virtual void MakePrincipals()
Perform the principal components analysis.
Definition: TPrincipal.cxx:950
Int_t fNumberOfDataPoints
Definition: TPrincipal.h:31
virtual void Clear(Option_t *option="")
Clear the data in Object.
Definition: TPrincipal.cxx:568
Bool_t fStoreData
Definition: TPrincipal.h:50
const Double_t * GetRow(Int_t row)
Return a row of the user supplied data.
Definition: TPrincipal.cxx:595
double Double_t
Definition: RtypesCore.h:55
TPrincipal & operator=(const TPrincipal &)
assignement operator
Definition: TPrincipal.cxx:337
#define name(a, b)
Definition: linkTestLib0.cpp:5
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
Definition: TPrincipal.h:74
TVectorD fOffDiagonal
Definition: TPrincipal.h:41
virtual void MakeCode(const char *filename="pca", Option_t *option="")
Generates the file , with .C appended if it does argument doesn't end in ...
Definition: TPrincipal.cxx:632
const TVectorD * GetSigmas() const
Definition: TPrincipal.h:72
const Bool_t kTRUE
Definition: Rtypes.h:91
TMatrixD fCovarianceMatrix
Definition: TPrincipal.h:36
TVectorD fSigmas
Definition: TPrincipal.h:35
TPrincipal()
Empty CTOR, Do not use.
Definition: TPrincipal.cxx:233