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(Int_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;
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 override { 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 void Print(Option_t *opt="MSE") const override; // *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 ClassDefOverride(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
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
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
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:63
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:61
Bool_t IsFolder() const override
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition TPrincipal.h:67
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:66
~TPrincipal() override
Destructor.
const TVectorD * GetEigenValues() const
Definition TPrincipal.h:60
const TVectorD * GetSigmas() const
Definition TPrincipal.h:65
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: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
Normalize matrix?
Definition TPrincipal.h:42
TPrincipal & operator=(const TPrincipal &)
Assignment operator.
Double_t x[n]
Definition legend1.C:17