Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
19class TList;
20
21class TPrincipal : public TNamed {
22
23protected:
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
51public:
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
#define b(i)
Definition RSha256.hxx:100
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
const Bool_t kTRUE
Definition RtypesCore.h:91
const char Option_t
Definition RtypesCore.h:66
#define ClassDef(name, id)
Definition Rtypes.h:325
char name[80]
Definition TGX11.cxx:110
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
A doubly linked list.
Definition TList.h:44
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Principal Components Analysis (PCA)
Definition TPrincipal.h:21
virtual void MakeMethods(const char *classname="PCA", Option_t *option="")
Generate the file <classname>PCA.cxx which contains the implementation of two methods:
virtual void AddRow(const Double_t *x)
Add a data point and update the covariance matrix.
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.
Double_t fTrace
Definition TPrincipal.h:38
virtual void Print(Option_t *opt="MSE") const
Print the statistics Options are.
const Double_t * GetRow(Int_t row)
Return a row of the user supplied data.
TPrincipal()
Empty constructor. Do not use.
const TMatrixD * GetCovarianceMatrix() const
Definition TPrincipal.h:59
virtual void Browse(TBrowser *b)
Browse the TPrincipal object in the TBrowser.
virtual void MakeHistograms(const char *name="pca", Option_t *option="epsdx")
Make histograms of the result of the analysis.
TVectorD fUserData
Definition TPrincipal.h:36
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 ....
TMatrixD fCovarianceMatrix
Definition TPrincipal.h:29
Int_t fNumberOfVariables
Definition TPrincipal.h:25
TVectorD fSigmas
Definition TPrincipal.h:28
TVectorD fOffDiagonal
Definition TPrincipal.h:34
TVectorD fEigenValues
Definition TPrincipal.h:32
virtual ~TPrincipal()
Destructor.
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition TPrincipal.h:67
const TVectorD * GetMeanValues() const
Definition TPrincipal.h:63
TVectorD fMeanValues
Definition TPrincipal.h:27
TList * fHistograms
Definition TPrincipal.h:40
const TMatrixD * GetEigenVectors() const
Definition TPrincipal.h:61
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...
Bool_t fStoreData
Definition TPrincipal.h:43
TMatrixD fEigenVectors
Definition TPrincipal.h:31
const TVectorD * GetUserData() const
Definition TPrincipal.h:66
const TVectorD * GetEigenValues() const
Definition TPrincipal.h:60
const TVectorD * GetSigmas() const
Definition TPrincipal.h:65
virtual void Clear(Option_t *option="")
Clear the data in Object.
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,...
Int_t fNumberOfDataPoints
Definition TPrincipal.h:24
void MakeNormalised()
Normalize the covariance matrix.
TList * GetHistograms() const
Definition TPrincipal.h:62
virtual void MakePrincipals()
Perform the principal components analysis.
virtual void SumOfSquareResiduals(const Double_t *x, Double_t *s)
Calculates the sum of the square residuals, that is.
void Test(Option_t *option="")
Test the PCA, bye calculating the sum square of residuals (see method SumOfSquareResiduals),...
Bool_t fIsNormalised
Definition TPrincipal.h:42
TPrincipal & operator=(const TPrincipal &)
Assignment operator.
Double_t x[n]
Definition legend1.C:17