aboutsummaryrefslogtreecommitdiffstats
path: root/pre_estimater/lin1d_estimater.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'pre_estimater/lin1d_estimater.hpp')
-rw-r--r--pre_estimater/lin1d_estimater.hpp52
1 files changed, 0 insertions, 52 deletions
diff --git a/pre_estimater/lin1d_estimater.hpp b/pre_estimater/lin1d_estimater.hpp
deleted file mode 100644
index 0a76df3..0000000
--- a/pre_estimater/lin1d_estimater.hpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef LIN1D_ESTIMATER
-#define LIN1D_ESTIMATER
-#include "pre_estimater.hpp"
-#include <misc/optvec.hpp>
-#include <models/lin1d.hpp>
-#include <vector>
-
-namespace opt_utilities
-{
- template <typename T>
- class lin1d_estimater
- :public pre_estimater<T,T,std::vector<T>,std::string>
- {
- public:
- lin1d_estimater()
- {
- this->set_model_id("1d linear model");
- }
-
- lin1d_estimater<T>* do_clone()const
- {
- return new lin1d_estimater<T>(*this);
- }
-
- void do_estimate(const data_set<T,T>& d,model<T,T,std::vector<T>,std::string>& m)const
- {
- T n=d.size();
- T sy=0;
- T sxx=0;
- T sx=0;
- T sxy=0;
-
- for(int i=0;i<d.size();++i)
- {
- sy+=d.get_data(i).get_y();
- sxx+=d.get_data(i).get_x()*d.get_data(i).get_x();
- sx+=d.get_data(i).get_x();
- sxy+=d.get_data(i).get_x()*d.get_data(i).get_y();
- }
- T b=(sy*sxx-sx*sxy)/(n*sxx-sx*sx);
- T k=(n*sxy-sx*sy)/(n*sxx-sx*sx);
-
- m.set_param_value("k",k);
- m.set_param_value("b",b);
-
- }
- };
-}
-
-
-
-#endif