From db1d374b7a24b8f3f74e17d706704d93f1e66d90 Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Mon, 8 Feb 2010 09:23:14 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@110 ed2142bd-67ad-457f-ba7c-d818d4011675 --- statistics/chisq.hpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'statistics') 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;jget_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; } }; - + } -- cgit v1.2.2