diff options
author | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2011-05-01 13:12:34 +0000 |
---|---|---|
committer | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2011-05-01 13:12:34 +0000 |
commit | fd6197d5d08da27bc3f8f4c7787aadf31f91b032 (patch) | |
tree | 6d85a21e1796e022e0bc79c13a5fb7293167706d /pre_estimaters | |
parent | d65b235ff380aeb29807b591bd709aceecd32284 (diff) | |
download | opt-utilities-fd6197d5d08da27bc3f8f4c7787aadf31f91b032.tar.bz2 |
git-svn-id: file:///home/svn/opt_utilities@189 ed2142bd-67ad-457f-ba7c-d818d4011675
Diffstat (limited to 'pre_estimaters')
-rw-r--r-- | pre_estimaters/vdualgauss1d_estimater.hpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/pre_estimaters/vdualgauss1d_estimater.hpp b/pre_estimaters/vdualgauss1d_estimater.hpp new file mode 100644 index 0000000..2be4cfb --- /dev/null +++ b/pre_estimaters/vdualgauss1d_estimater.hpp @@ -0,0 +1,73 @@ +#ifndef VDUALGAUSS1D_ESTIMATER +#define VDUALGAUSS1D_ESTIMATER +#include <core/pre_estimater.hpp> +#include <misc/optvec.hpp> +#include <vmodels/dualgauss1d.hpp> +#include <vector> + +namespace opt_utilities +{ + template <typename T> + class dualgauss1d_estimater + :public pre_estimater<optvec<T>,optvec<T>,optvec<T>,std::string> + { + public: + dualgauss1d_estimater() + { + this->set_model_id("1d dualgaussian"); + } + + dualgauss1d_estimater<T>* do_clone()const + { + return new dualgauss1d_estimater<T>(*this); + } + + void do_estimate(const data_set<optvec<T>,optvec<T> >& d,model<optvec<T>,optvec<T>,optvec<T>,std::string>& m)const + { + int n=d.size(); + + T xp1st=0; + T xp2nd=0; + T yp1st=d.get_data(0).get_y()[0]; + T yp2nd=d.get_data(0).get_y()[0]; + + for(int i=0;i<n;++i) + { + if(d.get_data(i).get_y()[0]>yp1st) + { + yp1st=d.get_data(i).get_y()[0]; + xp1st=d.get_data(i).get_x()[0]; + } + } + + for(int i=0;i<n;++i) + { + + } + + + T xmean=0; + T x2mean=0; + T wgt=0; + T wgt2=0; + for(int i=0;i<n;++i) + { + T x=d.get_data(i).get_x()[0]; + T y=d.get_data(i).get_y()[0]; + xmean+=x*y; + x2mean+=x*x*y; + wgt+=y; + } + xmean/=wgt; + x2mean/=wgt; + T sigma=std::sqrt(x2mean-xmean*xmean); + m.set_param_value("x0",xmean); + m.set_param_value("sigma",sigma); + + } + }; +} + + + +#endif |