Logo ROOT  
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 
19 class TList;
20 
21 class TPrincipal : public TNamed {
22 
23 protected:
24  Int_t fNumberOfDataPoints; // Number of data points
25  Int_t fNumberOfVariables; // Number of variables
26 
27  TVectorD fMeanValues; // Mean value over all data points
28  TVectorD fSigmas; // vector of sigmas
29  TMatrixD fCovarianceMatrix; // Covariance matrix
30 
31  TMatrixD fEigenVectors; // Eigenvector matrix of trans
32  TVectorD fEigenValues; // Eigenvalue vector of trans
33 
34  TVectorD fOffDiagonal; // elements of the tridiagonal
35 
36  TVectorD fUserData; // Vector of original data points
37 
38  Double_t fTrace; // Trace of covarience matrix
39 
40  TList *fHistograms; // List of histograms
41 
42  Bool_t fIsNormalised; // Normalize matrix?
43  Bool_t fStoreData; // Should we store input data?
44 
45  TPrincipal(const TPrincipal&);
47 
48  void MakeNormalised();
49  void MakeRealCode(const char *filename, const char *prefix, Option_t *option="");
50 
51 public:
52  TPrincipal();
53  virtual ~TPrincipal();
54  TPrincipal(Int_t nVariables, Option_t *opt="ND");
55 
56  virtual void AddRow(const Double_t *x);
57  virtual void Browse(TBrowser *b);
58  virtual void Clear(Option_t *option="");
60  const TVectorD *GetEigenValues() const {return &fEigenValues;}
61  const TMatrixD *GetEigenVectors() const {return &fEigenVectors;}
62  TList *GetHistograms() const {return fHistograms;}
63  const TVectorD *GetMeanValues() const {return &fMeanValues;}
64  const Double_t *GetRow(Int_t row);
65  const TVectorD *GetSigmas() const {return &fSigmas;}
66  const TVectorD *GetUserData() const {return &fUserData;}
67  Bool_t IsFolder() const { return kTRUE;}
68  virtual void MakeCode(const char *filename ="pca", Option_t *option=""); // *MENU*
69  virtual void MakeHistograms(const char *name = "pca", Option_t *option="epsdx"); // *MENU*
70  virtual void MakeMethods(const char *classname = "PCA", Option_t *option=""); // *MENU*
71  virtual void MakePrincipals(); // *MENU*
72  virtual void P2X(const Double_t *p, Double_t *x, Int_t nTest);
73  virtual void Print(Option_t *opt="MSE") const; // *MENU*
74  virtual void SumOfSquareResiduals(const Double_t *x, Double_t *s);
75  void Test(Option_t *option=""); // *MENU*
76  virtual void X2P(const Double_t *x, Double_t *p);
77 
78  ClassDef(TPrincipal,2) // Principal Components Analysis
79 }
80 ;
81 
82 #endif
TPrincipal::Clear
virtual void Clear(Option_t *option="")
Clear the data in Object.
Definition: TPrincipal.cxx:480
TPrincipal::fStoreData
Bool_t fStoreData
Definition: TPrincipal.h:43
TPrincipal::MakeHistograms
virtual void MakeHistograms(const char *name="pca", Option_t *option="epsdx")
Make histograms of the result of the analysis.
Definition: TPrincipal.cxx:569
TPrincipal::X2P
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.
Definition: TPrincipal.cxx:1215
TPrincipal::GetRow
const Double_t * GetRow(Int_t row)
Return a row of the user supplied data.
Definition: TPrincipal.cxx:507
TBrowser
Definition: TBrowser.h:37
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TVectorD.h
TPrincipal::AddRow
virtual void AddRow(const Double_t *x)
Add a data point and update the covariance matrix.
Definition: TPrincipal.cxx:410
TPrincipal::GetCovarianceMatrix
const TMatrixD * GetCovarianceMatrix() const
Definition: TPrincipal.h:59
TPrincipal::MakePrincipals
virtual void MakePrincipals()
Perform the principal components analysis.
Definition: TPrincipal.cxx:869
TPrincipal::IsFolder
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition: TPrincipal.h:67
TNamed.h
TPrincipal::GetSigmas
const TVectorD * GetSigmas() const
Definition: TPrincipal.h:65
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:168
Int_t
int Int_t
Definition: RtypesCore.h:45
TPrincipal::GetEigenVectors
const TMatrixD * GetEigenVectors() const
Definition: TPrincipal.h:61
TPrincipal::fNumberOfDataPoints
Int_t fNumberOfDataPoints
Definition: TPrincipal.h:24
TPrincipal::operator=
TPrincipal & operator=(const TPrincipal &)
Assignment operator.
Definition: TPrincipal.cxx:333
x
Double_t x[n]
Definition: legend1.C:17
TPrincipal::fOffDiagonal
TVectorD fOffDiagonal
Definition: TPrincipal.h:34
TPrincipal::fCovarianceMatrix
TMatrixD fCovarianceMatrix
Definition: TPrincipal.h:29
TPrincipal::GetMeanValues
const TVectorD * GetMeanValues() const
Definition: TPrincipal.h:63
TPrincipal::TPrincipal
TPrincipal()
Empty constructor. Do not use.
Definition: TPrincipal.cxx:229
TMatrixT
Definition: TMatrixDfwd.h:22
TPrincipal::GetEigenValues
const TVectorD * GetEigenValues() const
Definition: TPrincipal.h:60
TPrincipal::GetUserData
const TVectorD * GetUserData() const
Definition: TPrincipal.h:66
b
#define b(i)
Definition: RSha256.hxx:118
bool
TPrincipal::GetHistograms
TList * GetHistograms() const
Definition: TPrincipal.h:62
TPrincipal::MakeCode
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 ....
Definition: TPrincipal.cxx:544
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TPrincipal::P2X
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,...
Definition: TPrincipal.cxx:1060
TPrincipal::fHistograms
TList * fHistograms
Definition: TPrincipal.h:40
TNamed
Definition: TNamed.h:29
TPrincipal
Definition: TPrincipal.h:21
TPrincipal::Browse
virtual void Browse(TBrowser *b)
Browse the TPrincipal object in the TBrowser.
Definition: TPrincipal.cxx:457
TPrincipal::SumOfSquareResiduals
virtual void SumOfSquareResiduals(const Double_t *x, Double_t *s)
Calculates the sum of the square residuals, that is.
Definition: TPrincipal.cxx:1169
TPrincipal::fSigmas
TVectorD fSigmas
Definition: TPrincipal.h:28
TPrincipal::fEigenVectors
TMatrixD fEigenVectors
Definition: TPrincipal.h:31
TPrincipal::fIsNormalised
Bool_t fIsNormalised
Definition: TPrincipal.h:42
TPrincipal::Print
virtual void Print(Option_t *opt="MSE") const
Print the statistics Options are.
Definition: TPrincipal.cxx:1080
TVectorT
Definition: TMatrixTBase.h:78
TPrincipal::~TPrincipal
virtual ~TPrincipal()
Destructor.
Definition: TPrincipal.cxx:357
TPrincipal::MakeRealCode
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:891
Double_t
double Double_t
Definition: RtypesCore.h:59
TPrincipal::fMeanValues
TVectorD fMeanValues
Definition: TPrincipal.h:27
TPrincipal::fNumberOfVariables
Int_t fNumberOfVariables
Definition: TPrincipal.h:25
TPrincipal::MakeMethods
virtual void MakeMethods(const char *classname="PCA", Option_t *option="")
Generate the file <classname>PCA.cxx which contains the implementation of two methods:
Definition: TPrincipal.cxx:856
TPrincipal::MakeNormalised
void MakeNormalised()
Normalize the covariance matrix.
Definition: TPrincipal.cxx:794
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TPrincipal::Test
void Test(Option_t *option="")
Test the PCA, bye calculating the sum square of residuals (see method SumOfSquareResiduals),...
Definition: TPrincipal.cxx:1191
name
char name[80]
Definition: TGX11.cxx:110
TMatrixD.h
TPrincipal::fEigenValues
TVectorD fEigenValues
Definition: TPrincipal.h:32
TPrincipal::fTrace
Double_t fTrace
Definition: TPrincipal.h:38
TList
Definition: TList.h:44
TPrincipal::fUserData
TVectorD fUserData
Definition: TPrincipal.h:36
int