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 ~TPrincipal() override;
54 TPrincipal(Long64_t nVariables, Option_t *opt="ND");
55
56 virtual void AddRow(const Double_t *x);
57 void Browse(TBrowser *b) override;
58 void Clear(Option_t *option="") override;
59 /// Return the covariance matrix. \note Only the lower diagonal of the covariance matrix is computed by the class
61 const TVectorD *GetEigenValues() const {return &fEigenValues;}
62 const TMatrixD *GetEigenVectors() const {return &fEigenVectors;}
63 TList *GetHistograms() const {return fHistograms;}
64 const TVectorD *GetMeanValues() const {return &fMeanValues;}
65 const Double_t *GetRow(Long64_t row);
66 const TVectorD *GetSigmas() const {return &fSigmas;}
67 const TVectorD *GetUserData() const {return &fUserData;}
68 Bool_t IsFolder() const override { return kTRUE;}
69 virtual void MakeCode(const char *filename ="pca", Option_t *option=""); // *MENU*
70 virtual void MakeHistograms(const char *name = "pca", Option_t *option="epsdx"); // *MENU*
71 virtual void MakeMethods(const char *classname = "PCA", Option_t *option=""); // *MENU*
72 virtual void MakePrincipals(); // *MENU*
73 virtual void P2X(const Double_t *p, Double_t *x, Int_t nTest);
74 void Print(Option_t *opt="MSE") const override; // *MENU*
75 virtual void SumOfSquareResiduals(const Double_t *x, Double_t *s);
76 void Test(Option_t *option=""); // *MENU*
77 virtual void X2P(const Double_t *x, Double_t *p);
78
79 ClassDefOverride(TPrincipal,2) // Principal Components Analysis
80}
81;
82
83#endif
#define b(i)
Definition RSha256.hxx:100
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:80
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
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:38
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
Trace of covarience matrix.
Definition TPrincipal.h:38
TPrincipal()
Empty constructor. Do not use.
const TMatrixD * GetCovarianceMatrix() const
Return the covariance matrix.
Definition TPrincipal.h:60
void Clear(Option_t *option="") override
Clear the data in Object.
virtual void MakeHistograms(const char *name="pca", Option_t *option="epsdx")
Make histograms of the result of the analysis.
void Print(Option_t *opt="MSE") const override
Print the statistics Options are.
TVectorD fUserData
Vector of original data points.
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
Covariance matrix.
Definition TPrincipal.h:29
Int_t fNumberOfVariables
Number of variables.
Definition TPrincipal.h:25
TVectorD fSigmas
vector of sigmas
Definition TPrincipal.h:28
TVectorD fOffDiagonal
Elements of the tridiagonal.
Definition TPrincipal.h:34
TVectorD fEigenValues
Eigenvalue vector of trans.
Definition TPrincipal.h:32
const TVectorD * GetMeanValues() const
Definition TPrincipal.h:64
TVectorD fMeanValues
Mean value over all data points.
Definition TPrincipal.h:27
TList * fHistograms
List of histograms.
Definition TPrincipal.h:40
const TMatrixD * GetEigenVectors() const
Definition TPrincipal.h:62
Bool_t IsFolder() const override
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition TPrincipal.h:68
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
Should we store input data?
Definition TPrincipal.h:43
TMatrixD fEigenVectors
Eigenvector matrix of trans.
Definition TPrincipal.h:31
const TVectorD * GetUserData() const
Definition TPrincipal.h:67
~TPrincipal() override
Destructor.
const TVectorD * GetEigenValues() const
Definition TPrincipal.h:61
const TVectorD * GetSigmas() const
Definition TPrincipal.h:66
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,...
void Browse(TBrowser *b) override
Browse the TPrincipal object in the TBrowser.
Int_t fNumberOfDataPoints
Number of data points.
Definition TPrincipal.h:24
void MakeNormalised()
Normalize the covariance matrix.
TList * GetHistograms() const
Definition TPrincipal.h:63
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.
const Double_t * GetRow(Long64_t row)
Return a row of the user supplied data.
void Test(Option_t *option="")
Test the PCA, bye calculating the sum square of residuals (see method SumOfSquareResiduals),...
Bool_t fIsNormalised
Normalize matrix?
Definition TPrincipal.h:42
TPrincipal & operator=(const TPrincipal &)
Assignment operator.
Double_t x[n]
Definition legend1.C:17