ROOT
6.10/09
Reference Guide
documentation
doxygen
pca.C
Go to the documentation of this file.
1
// -*- mode: c++ -*-
2
//
3
// File pca.C generated by TPrincipal::MakeCode
4
// on Thu May 31 12:01:24 2018
5
// ROOT version 6.10/09
6
//
7
// This file contains the functions
8
//
9
// void X2P(Double_t *x, Double_t *p);
10
// void P2X(Double_t *p, Double_t *x, Int_t nTest);
11
//
12
// The first for transforming original data x in
13
// pattern space, to principal components p in
14
// feature space. The second function is for the
15
// inverse transformation, but using only nTest
16
// of the principal components in the expansion
17
//
18
// See TPrincipal class documentation for more information
19
//
20
#ifndef __CINT__
21
#include <
Rtypes.h
>
// needed for Double_t etc
22
#endif
23
24
//
25
// Static data variables
26
//
27
static
Int_t
gNVariables
= 10;
28
29
// Assignment of eigenvector matrix.
30
// Elements are stored row-wise, that is
31
// M[i][j] = e[i * nVariables + j]
32
// where i and j are zero-based
33
static
Double_t
gEigenVectors
[] = {
34
0.105952,
35
-0.0412338,
36
-0.163932,
37
0.506955,
38
-0.293327,
39
-0.45912,
40
0.611921,
41
0.0417098,
42
0.124369,
43
-0.121286,
44
0.299103,
45
0.114816,
46
-0.423035,
47
0.173049,
48
0.129852,
49
-0.264772,
50
-0.58561,
51
0.118711,
52
0.35397,
53
-0.345193,
54
0.196631,
55
0.182178,
56
0.334538,
57
0.0979602,
58
-0.695575,
59
0.431875,
60
-0.124202,
61
0.0811669,
62
0.242022,
63
-0.236021,
64
0.0946521,
65
0.0513485,
66
0.107011,
67
0.552681,
68
0.561861,
69
0.539862,
70
0.180077,
71
0.041718,
72
0.124394,
73
-0.121309,
74
0.294184,
75
0.179444,
76
0.157981,
77
-0.594249,
78
0.257622,
79
-0.0673251,
80
0.421439,
81
0.117814,
82
0.351295,
83
-0.342585,
84
0.135669,
85
-0.895902,
86
-0.0723783,
87
-0.0912176,
88
-0.0511243,
89
0.155245,
90
0.0072091,
91
-0.0686794,
92
0.36119,
93
0.0587528,
94
0.0393664,
95
-0.129504,
96
0.791462,
97
0.188712,
98
0.167449,
99
-0.456201,
100
-0.235961,
101
-0.142627,
102
0.0747034,
103
-0.0435387,
104
0.501306,
105
-0.134663,
106
0.0961035,
107
0.0147716,
108
0.015782,
109
-0.0347285,
110
-0.0292305,
111
0.724996,
112
-0.379729,
113
0.221314,
114
0.503961,
115
-0.111486,
116
-0.060855,
117
-0.0228244,
118
-0.0175214,
119
0.0561781,
120
0.0175518,
121
-0.534241,
122
-0.552628,
123
-0.367135,
124
0.4898,
125
0.259068,
126
-0.0353844,
127
0.0139158,
128
0.00266293,
129
-0.00485772,
130
0.0160046,
131
-0.354777,
132
0.275952,
133
0.69945};
134
135
// Assignment to eigen value vector. Zero-based.
136
static
Double_t
gEigenValues
[] = {
137
0.385122,
138
0.110703,
139
0.103572,
140
0.101548,
141
0.100795,
142
0.0996221,
143
0.0986388,
144
5.97928e-16,
145
2.52544e-16,
146
5.65803e-16
147
};
148
149
// Assignment to mean value vector. Zero-based.
150
static
Double_t
gMeanValues
[] = {
151
5.0082,
152
7.9976,
153
1.96735,
154
5.0162,
155
8.0087,
156
2.01253,
157
4.99247,
158
35.0031,
159
30.0106,
160
27.9981
161
};
162
163
// Assignment to sigma value vector. Zero-based.
164
static
Double_t
gSigmaValues
[] = {
165
1.00507,
166
2.86056,
167
1.95587,
168
1.00527,
169
2.83895,
170
1.97263,
171
1.01426,
172
5.15563,
173
5.04925,
174
4.64883
175
};
176
177
//
178
// The function void X2P(Double_t *x, Double_t *p)
179
//
180
void
X2P
(
Double_t
*
x
,
Double_t
*p) {
181
for
(
Int_t
i = 0; i <
gNVariables
; i++) {
182
p[i] = 0;
183
for
(
Int_t
j = 0; j <
gNVariables
; j++)
184
p[i] += (x[j] -
gMeanValues
[j])
185
*
gEigenVectors
[j * gNVariables + i] /
gSigmaValues
[j];
186
187
}
188
}
189
190
//
191
// The function void P2X(Double_t *p, Double_t *x, Int_t nTest)
192
//
193
void
P2X
(
Double_t
*p,
Double_t
*
x
,
Int_t
nTest) {
194
for
(
Int_t
i = 0; i <
gNVariables
; i++) {
195
x[i] =
gMeanValues
[i];
196
for
(
Int_t
j = 0; j < nTest; j++)
197
x[i] += p[j] *
gSigmaValues
[i]
198
*
gEigenVectors
[i * gNVariables + j];
199
}
200
}
201
202
// EOF for pca.C
X2P
void X2P(Double_t *x, Double_t *p)
Definition:
pca.C:180
Rtypes.h
gNVariables
static Int_t gNVariables
Definition:
pca.C:27
Int_t
int Int_t
Definition:
RtypesCore.h:41
gEigenVectors
static Double_t gEigenVectors[]
Definition:
pca.C:33
x
Double_t x[n]
Definition:
legend1.C:17
gSigmaValues
static Double_t gSigmaValues[]
Definition:
pca.C:164
P2X
void P2X(Double_t *p, Double_t *x, Int_t nTest)
Definition:
pca.C:193
gEigenValues
static Double_t gEigenValues[]
Definition:
pca.C:136
Double_t
double Double_t
Definition:
RtypesCore.h:55
gMeanValues
static Double_t gMeanValues[]
Definition:
pca.C:150