diff options
Diffstat (limited to 'statistics')
-rw-r--r-- | statistics/chisq.hpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/statistics/chisq.hpp b/statistics/chisq.hpp index 339ab6f..c460394 100644 --- a/statistics/chisq.hpp +++ b/statistics/chisq.hpp @@ -247,14 +247,26 @@ namespace opt_utilities Ts result(0);
for(int i=(this->get_data_set()).size()-1;i>=0;--i)
{
- Ty chi=(this->get_data_set().get_data(i).get_y()-eval_model(this->get_data_set().get_data(i).get_x(),p))/this->get_data_set().get_data(i).get_y_upper_err();
+ Ty chi(this->get_data_set().get_data(0).get_y().size());
+ for(int j=0;j<chi.size();++j)
+ {
+ Ty model_y(eval_model(this->get_data_set().get_data(i).get_x(),p));
+ if(model_y[j]>this->get_data_set().get_data(i).get_y()[j])
+ {
+ chi[j]=(this->get_data_set().get_data(i).get_y()[j]-model_y[j])/this->get_data_set().get_data(i).get_y_upper_err()[j];
+ }
+ else
+ {
+ chi[j]=(this->get_data_set().get_data(i).get_y()[j]-model_y[j])/this->get_data_set().get_data(i).get_y_lower_err()[j];
+ }
+ }
result+=sum(chi*chi);
-
+
}
return result;
}
};
-
+
}
|