-double obs_phi2::phi2Sus(vector< vector<double> > *vals, void *para) {
- double mean=0, mean2=0;
- for(vector< vector<double> >::iterator valIt = vals->begin(); valIt != vals->end(); ++valIt)
- {
- mean += (*valIt)[0];
- mean2 += pow((*valIt)[0],2);
- }
- mean /= vals->size();
- mean2 /= vals->size();
-
- return ( mean2 - pow(mean,2) ) * *(int*)para;
+void obs_phi2::prePhi2Sus(vector< vector <double> > *allVals, vector <double> *preCalculated, void *para) {
+ preCalculated->push_back(0);
+ preCalculated->push_back(0);
+
+ for(vector< vector<double> >::iterator valIt = allVals->begin(); valIt != allVals->end(); ++valIt) {
+ (*preCalculated)[0] += (*valIt)[0];
+ (*preCalculated)[1] += pow((*valIt)[0],2);
+ }
+}
+
+double obs_phi2::phi2Sus(vector <double> *preCalculated, vector<double> *excludedMeas, int nmeas, void *para) {
+ return (( (*preCalculated)[1] - pow((*excludedMeas)[0], 2) )
+ - pow( (*preCalculated)[0] - (*excludedMeas)[0], 2 ))
+ * *(int*)para
+ / (nmeas-1);