Ress.h
Go to the documentation of this file.
1 /** Ress is an interface to wire-cell-ress
2  */
3 #ifndef WIRECELL_RESS_HEADER_SEEN
4 #define WIRECELL_RESS_HEADER_SEEN
5 
6 #include <Eigen/Dense>
7 
8 namespace WireCell {
9 
10  namespace Ress {
11 
12  typedef Eigen::VectorXd vector_t;
13  typedef Eigen::MatrixXd matrix_t;
14 
15  enum Model {
17  lasso, // Lasso model
18  elnet // elastic net
19  };
20 
21  struct Params {
23  double lambda = 1.0;
24  int max_iter = 100000;
25  double tolerance = 1e-3;
26  bool non_negative = true;
27  double alpha = 1.0;
28  };
29 
30  // Solve m = R*s for s, return s.
31  vector_t solve(
32  // matrix R
33  matrix_t response,
34  // measured vector m
35  vector_t measured,
36  // params
37  const Params& params = Params(),
38  // optional initial source s
39  vector_t source = Eigen::VectorXd(),
40  // optional initial measurement weights
41  vector_t weights = Eigen::VectorXd()
42  );
43 
44  vector_t predict(matrix_t response, vector_t source);
45 
46  double chi2(vector_t measured, vector_t predicted);
47 
48  double mean_residual(vector_t measured, vector_t predicted);
49 
50  double chi2_l1(vector_t measured, vector_t solved, double lambda = 1.0);
51 
52  } // namespace Ress
53 
54 
55 
56 } // WireCell
57 
58 
59 #endif /* WIRECELL_RESS */
double chi2(vector_t measured, vector_t predicted)
Definition: Ress.cxx:57
vector_t predict(matrix_t response, vector_t source)
Definition: Ress.cxx:52
vector_t solve(matrix_t response, vector_t measured, const Params &params=Params(), vector_t source=Eigen::VectorXd(), vector_t weights=Eigen::VectorXd())
Definition: Ress.cxx:7
Eigen::VectorXd vector_t
Definition: Ress.h:12
double mean_residual(vector_t measured, vector_t predicted)
Definition: Ress.cxx:62
Eigen::MatrixXd matrix_t
Definition: Ress.h:13
const double e
double chi2_l1(vector_t measured, vector_t solved, double lambda=1.0)
Definition: Ress.cxx:47
Definition: Main.h:22
double tolerance
Definition: Ress.h:25