/** \file cstat.hpp */ #ifndef CSTAT_HPP #define CSTAT_HPP #define OPT_HEADER #include #include #include #include using std::cout;using std::endl; namespace opt_utilities { /** \brief c-statistic, max-likelihood method \tparam Ty the return type of model \tparam Tx the type of the self-var \tparam Tp the type of model parameter \tparam Ts the type of the statistic \tparam Tstr the type of the string used */ template class cstat :public statistic { private: bool verb; int n; public: cstat() :verb(true) {} void verbose(bool v) { verb=v; } public: statistic* do_clone()const { // return const_cast*>(this); return new cstat(*this); } Ts do_eval(const Tp& p) { Ts result(0); 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-=contract(this->get_data_set().get_data(i).get_y(),std::log(model_y),result); } if(verb) { n++; if(n%10==0) { cout<<"a:"<