Logo ROOT  
Reference Guide
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Christian Holm Christensen 1/8/2000
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#include "TNamed.h"
16#include "TVectorD.h"
17#include "TMatrixD.h"
18#include "TList.h"
20class TPrincipal : public TNamed {
23 Int_t fNumberOfDataPoints; // Number of data points
24 Int_t fNumberOfVariables; // Number of variables
26 TVectorD fMeanValues; // Mean value over all data points
27 TVectorD fSigmas; // vector of sigmas
28 TMatrixD fCovarianceMatrix; // Covariance matrix
30 TMatrixD fEigenVectors; // Eigenvector matrix of trans
31 TVectorD fEigenValues; // Eigenvalue vector of trans
33 TVectorD fOffDiagonal; // elements of the tridiagonal
35 TVectorD fUserData; // Vector of original data points
37 Double_t fTrace; // Trace of covarience matrix
39 TList *fHistograms; // List of histograms
41 Bool_t fIsNormalised; // Normalize matrix?
42 Bool_t fStoreData; // Should we store input data?
44 TPrincipal(const TPrincipal&);
47 void MakeNormalised();
48 void MakeRealCode(const char *filename, const char *prefix, Option_t *option="");
51 TPrincipal();
52 virtual ~TPrincipal();
53 TPrincipal(Int_t nVariables, Option_t *opt="ND");
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);
77 ClassDef(TPrincipal,2) // Principal Components Analysis
#define b(i)
Definition: RSha256.hxx:100
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:326
char name[80]
Definition: TGX11.cxx:109
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:20
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
virtual void AddRow(const Double_t *x)
Add a data point and update the covariance matrix.
Definition: TPrincipal.cxx:410
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:37
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.
Definition: TPrincipal.cxx:507
Empty constructor. Do not use.
Definition: TPrincipal.cxx:229
const TMatrixD * GetCovarianceMatrix() const
Definition: TPrincipal.h:58
virtual void Browse(TBrowser *b)
Browse the TPrincipal object in the TBrowser.
Definition: TPrincipal.cxx:457
virtual void MakeHistograms(const char *name="pca", Option_t *option="epsdx")
Make histograms of the result of the analysis.
Definition: TPrincipal.cxx:569
TVectorD fUserData
Definition: TPrincipal.h:35
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
TMatrixD fCovarianceMatrix
Definition: TPrincipal.h:28
Int_t fNumberOfVariables
Definition: TPrincipal.h:24
TVectorD fSigmas
Definition: TPrincipal.h:27
TVectorD fOffDiagonal
Definition: TPrincipal.h:33
TVectorD fEigenValues
Definition: TPrincipal.h:31
virtual ~TPrincipal()
Definition: TPrincipal.cxx:357
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition: TPrincipal.h:66
const TVectorD * GetMeanValues() const
Definition: TPrincipal.h:62
TVectorD fMeanValues
Definition: TPrincipal.h:26
TList * fHistograms
Definition: TPrincipal.h:39
const TMatrixD * GetEigenVectors() const
Definition: TPrincipal.h:60
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
Bool_t fStoreData
Definition: TPrincipal.h:42
TMatrixD fEigenVectors
Definition: TPrincipal.h:30
const TVectorD * GetUserData() const
Definition: TPrincipal.h:65
const TVectorD * GetEigenValues() const
Definition: TPrincipal.h:59
const TVectorD * GetSigmas() const
Definition: TPrincipal.h:64
virtual void Clear(Option_t *option="")
Clear the data in Object.
Definition: TPrincipal.cxx:480
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:23
void MakeNormalised()
Normalize the covariance matrix.
Definition: TPrincipal.cxx:794
TList * GetHistograms() const
Definition: TPrincipal.h:61
virtual void MakePrincipals()
Perform the principal components analysis.
Definition: TPrincipal.cxx:869
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:41
TPrincipal & operator=(const TPrincipal &)
Assignment operator.
Definition: TPrincipal.cxx:333
Double_t x[n]
Definition: legend1.C:17
static constexpr double s