From 9fcda2d737def25854456a64d4d8c6f24771341f Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Sun, 16 Aug 2009 11:32:47 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@41 ed2142bd-67ad-457f-ba7c-d818d4011675 --- statistics/cstat.hpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'statistics/cstat.hpp') diff --git a/statistics/cstat.hpp b/statistics/cstat.hpp index ce8469e..058523d 100644 --- a/statistics/cstat.hpp +++ b/statistics/cstat.hpp @@ -7,19 +7,17 @@ using std::cout;using std::endl; namespace opt_utilities { template - class cstat_poisson + class cstat :public statistic { private: bool verb; int n; - - Ty lnfrac(Ty y)const - { - return y*log(y)-y; - } - public: + cstat() + :verb(true) + {} + void verbose(bool v) { verb=v; @@ -29,7 +27,7 @@ namespace opt_utilities statistic* do_clone()const { // return const_cast*>(this); - return new cstat_poisson(*this); + return new cstat(*this); } Ts do_eval(const Tp& p) @@ -38,7 +36,7 @@ namespace opt_utilities for(int i=(this->get_data_set()).size()-1;i>=0;--i) { Ty model_y=eval_model(this->get_data_set().get_data(i).get_x(),p); - result+=model_y-this->get_data_set().get_data(i).get_y()*log(model_y)+lnfrac(this->get_data_set().get_data(i).get_y()); + result-=this->get_data_set().get_data(i).get_y()*std::log(model_y); } if(verb) @@ -46,7 +44,7 @@ namespace opt_utilities n++; if(n%10==0) { - cout<p_fitter->get_dof()<<"\t"; + cout<<"a:"<