KrisLibrary  1.0.0
LinearModel.h
1 #ifndef STATISTICS_LINEAR_MODEL_H
2 #define STATISTICS_LINEAR_MODEL_H
3 
4 #include "statistics.h"
5 
6 namespace Statistics {
7 
18 {
19  public:
20  enum SolveMethod { Cholesky, SVD, QR };
21 
22  LinearModel();
23  Real Evaluate(const Vector& x) const;
24  Real Variance(const Vector& x) const;
25  void CoeffVariance(Vector& coeffVariance) const;
26  bool LeastSquares(const Matrix& x,const Vector& outcome);
27  bool LeastSquares(const std::vector<Vector>& x,const std::vector<Real>& outcome);
28  bool LeastSquares(const std::vector<Vector>& x,int outcomeIndex);
29 
30  private:
31  bool LeastSquares_Internal(const Matrix& x,const Vector& outcome);
32  bool LeastSquares_Cholesky(const Matrix& x,const Vector& outcome);
33  bool LeastSquares_SVD(const Matrix& x,const Vector& outcome);
34  bool LeastSquares_QR(const Matrix& x,const Vector& outcome);
35  public:
36 
37  SolveMethod solveMethod;
38  bool constantOffset;
39 
40  Vector coeffs;
41  Matrix covariance;
42 };
43 
44 std::istream& operator >> (std::istream& in,LinearModel& model);
45 std::ostream& operator << (std::ostream& out,const LinearModel& model);
46 
47 } //namespace Statistics
48 
49 #endif
Contains all definitions in the statistics directory.
Definition: BernoulliDistribution.h:6
Basic statistical utilities.
A linear model of n-dimensional data.
Definition: LinearModel.h:17