diff options
Diffstat (limited to 'statistics')
-rw-r--r-- | statistics/chisq.hpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/statistics/chisq.hpp b/statistics/chisq.hpp index ed25051..4054c22 100644 --- a/statistics/chisq.hpp +++ b/statistics/chisq.hpp @@ -107,7 +107,7 @@ namespace opt_utilities #ifdef HAVE_X_ERROR
Tx x1=this->datas().get_data(i).get_x()-this->datas().get_data(i).get_x_lower_err();
Tx x2=this->datas().get_data(i).get_x()+this->datas().get_data(i).get_x_upper_err();
- Tx x=this->datas().get_data(i).get_x()+this->datas().get_data(i).get_x();
+ Tx x=this->datas().get_data(i).get_x();
Ty errx1=(eval_model(x1,p)-eval_model(x,p));
Ty errx2=(eval_model(x2,p)-eval_model(x,p));
//Ty errx=0;
@@ -121,13 +121,27 @@ namespace opt_utilities Ty y_err;
Ty errx=0;
- if(errx2>errx1)
+ if(errx1<errx2)
{
- errx=errx1>0?errx1:-errx1;
+ if(y_obs<y_model)
+ {
+ errx=errx1>0?errx1:-errx1;
+ }
+ else
+ {
+ errx=errx2>0?errx2:-errx2;
+ }
}
else
{
- errx=errx2>0?errx2:-errx2;
+ if(y_obs<y_model)
+ {
+ errx=errx2>0?errx2:-errx2;
+ }
+ else
+ {
+ errx=errx1>0?errx1:-errx1;
+ }
}
|