#ifndef ERROR_EST #define ERROR_EST #include #include #include #include #include namespace opt_utilities { template void estimate_error(fitter& fit,const Tstr& pname,typename element_type_trait::element_type& lower,typename element_type_trait::element_type& upper,const Ts& dchi,const Ts& precision) { typedef typename element_type_trait::element_type Tpe; std::vector pnames; std::vector pvalues; for(int i=0;i* pfp=dynamic_cast*>(&fit.get_param_modifier()); if(pfp==0) { assert(0); } *pfp+=freeze_param(pname); } catch(const param_modifier_undefined&) { fit.set_param_modifier(freeze_param(pname)); } Tpe current_value= fit.get_param_value(pname); if(lower>=current_value||upper<=current_value) { std::cerr<<"Error, initial lower and upper limits should be smaller and larger than the best fit value, respectively"<current_chi+dchi) { break; } upper+=step; } Ts target_chi=current_chi+dchi; while(upper-upper1>std::abs(precision)) { std::cerr<=0) { upper=(upper+upper1)/2; } else if((s1-target_chi)*(s01-target_chi)>0&&(s-target_chi)*(s01-target_chi)<=0) { upper1=(upper+upper1)/2; } else { std::cerr<<"strange statistic structure"<current_chi+dchi) { break; } lower-=step; } fit.set_param_value(pname,current_value); fit.fit(); while(lower1-lower>std::abs(precision)) { fit.set_param_value(pname,lower1); fit.fit(); Ts s1=fit.get_statistic_value(); fit.set_param_value(pname,lower); fit.fit(); Ts s=fit.get_statistic_value(); fit.set_param_value(pname,(lower+lower1)/2); fit.fit(); Ts s01=fit.get_statistic_value(); //std::cerr<<"l:"<=0) { lower=(lower+lower1)/2; } else if((s1-target_chi)*(s01-target_chi)>0&&(s-target_chi)*(s01-target_chi)<=0) { lower1=(lower+lower1)/2; } else { std::cerr<<"strange statistic structure"<& >(fit.get_param_modifier())-=freeze_param(pname); for(int i=0;i