19 #ifndef __INC_OPTIMIZER_GOAL_GLOBAL 20 #define __INC_OPTIMIZER_GOAL_GLOBAL 33 std::vector<std::pair<double, int> >
sorted;
35 std::vector<std::vector<double> >
data;
60 for (
unsigned int i=0; i<first.size() && i<second.size(); i++)
61 tmpf += (first[i] - second[i])*(first[i] - second[i]);
72 for (
unsigned int i=0; i<data.size(); i++)
74 sorted.push_back(std::make_pair(
dist(data[i],item), i));
76 std::sort(sorted.begin(), sorted.end(), comparePairs<double, int>);
79 for (
unsigned int i=trimming; i<sorted.size() -
trimming; i++)
80 ids.push_back(sorted[i].second);
85 double n = (double)ids.size();
89 item.resize(data[0].size(), 0.0);
90 for (
unsigned int i=0; i<ids.size(); i++)
91 for (
unsigned int j=0; j<item.size(); j++)
92 item[j] += data[ids[i]][j] / n;
96 double tmpf = 0.0, tmpf2;
97 for (
unsigned int i=0; i<ids.size(); i++)
99 tmpf2 =
dist(data[ids[i]], item);
100 tmpf += (tmpf2 * tmpf2) / n;
108 if (data.size() == 0)
113 std::vector<double> tmpMean;
114 for (
unsigned int i=0; i<data.size(); i++)
std::vector< double > item
std::vector< std::pair< double, int > > sorted
double dist(std::vector< double > &first, std::vector< double > &second)
void setTrimming(unsigned int value)
std::vector< std::vector< double > > data
std::vector< double > mean
double getTrimmedMeanAndVariance(std::vector< std::vector< double > > &data, int index, std::vector< double > &item)
virtual double getDistance()