-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpMSSM_test.cpp
More file actions
92 lines (80 loc) · 2.52 KB
/
pMSSM_test.cpp
File metadata and controls
92 lines (80 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <iostream>
#include <math.h>
#include <random>
#include <fstream> /// for reading from file
#include <sstream>
#include <string>
#include "adept.h"
#include "BNN.h"
// Provide function prototype for "algorithm"; see algorithm.cpp for
// the contents of the function
#include "algorithm.h"
int
main(int argc, char** argv)
{
std::ifstream infile("pMSSM_cross_sections_13TeV.txt");
int N = 500;
int in = 19;
int out = 1;
std::vector<HMC_type> data(N*in,1.0);
//std::vector<HMC_type> weights(np,1.0);
std::vector<HMC_type> target(N,1.0);
std::string line;
int n_inc = 0;
std::getline(infile,line);
line.clear();
while(std::getline(infile,line))
{
if(n_inc >= N) {std::cout << n_inc << " input events read\n" ;break;}
std::cout << line << std::endl;
std::istringstream iss(line);
iss >> target[n_inc];
for(int i=0;i<in;i++){
iss >> data[n_inc*in+i];
}
n_inc++;
}
std::vector<HMC_type> mean_data(in,0.0);
HMC_type mean_target = 0.0;
for(int j=0;j<N;j++){
mean_target += target[j];
// std::cout << "target[" << j << "] = " << target[j] << std::endl;
for(int i=0;i<in;i++){
mean_data[i]+= data[j*in+i];
//std::cout<< "data[" << j*in+i << "] = " << data[j*in+i] << std::endl;
}
}
mean_target = mean_target/(HMC_type)N;
for(int i=0;i<in;i++){mean_data[i] = mean_data[i]/(HMC_type)N;}
std::vector<HMC_type> dev_data(in,0.0);
HMC_type dev_target = 0.0;
for(int j=0;j<N;j++){
dev_target += pow(target[j]-mean_target,2);
// std::cout << "target[" << j << "] = " << target[j] << std::endl;
for(int i=0;i<in;i++){
dev_data[i]+= pow(data[j*in+i]-dev_data[i],2);
//std::cout<< "data[" << j*in+i << "] = " << data[j*in+i] << std::endl;
}
}
dev_target = sqrt(dev_target/(HMC_type)N);
for(int i=0;i<in;i++){dev_data[i] = sqrt(dev_data[i]/(HMC_type)N);}
for(int j=0;j<N;j++){
target[j] = (target[j]-mean_target)/dev_target;
// std::cout << "target[" << j << "] = " << target[j] << std::endl;
for(int i=0;i<in;i++){
data[j*in+i] = (data[j*in+i]-mean_data[i])/dev_data[i];
//std::cout<< "data[" << j*in+i << "] = " << data[j*in+i] << std::endl;
}
}
int L = 100;
int nOut = 50;
int nRep = 20;
int nBurn = 100;
int H = 22; /// number of hidden nodes
//int in = 2; /// number of inputs
int np = 1+H*(2+in);
std::vector<HMC_type> weights(N,1.0);
BNN HMC_BNN(L, nOut, nRep, nBurn, H, in, data, weights, target, "pMSSM_test.out");
HMC_BNN.run();
return 0;
}