18 void principal(Int_t n=10, Int_t m=10000)
22 cout <<
"*************************************************" << endl;
23 cout <<
"* Principal Component Analysis *" << endl;
24 cout <<
"* *" << endl;
25 cout <<
"* Number of variables: " << setw(4) << n
27 cout <<
"* Number of data points: " << setw(8) << m
29 cout <<
"* Number of dependent variables: " << setw(4) << c
31 cout <<
"* *" << endl;
32 cout <<
"*************************************************" << endl;
39 TPrincipal* principal =
new TPrincipal(n,
"ND");
42 TRandom* randumNum =
new TRandom;
47 Double_t* data =
new Double_t[n];
48 for (Int_t i = 0; i < m; i++) {
52 for (Int_t j = 0; j < n - c; j++) {
53 if (j % 3 == 0) data[j] = randumNum->Gaus(5,1);
54 else if (j % 3 == 1) data[j] = randumNum->Poisson(8);
55 else data[j] = randumNum->Exp(2);
59 for (Int_t j = 0 ; j < c; j++) {
61 for (Int_t k = 0; k < n - c - j; k++) data[n - c + j] += data[k];
65 principal->AddRow(data);
72 principal->MakePrincipals();
81 principal->MakeHistograms();
84 principal->MakeCode();
88 TBrowser* b =
new TBrowser(
"principalBrowser", principal);