53 #if !defined(LIBEVOCOSM_STATS_H)
54 #define LIBEVOCOSM_STATS_H
73 template <
class OrganismType>
96 : best(new OrganismType(a_population[0])),
97 worst(new OrganismType(a_population[0]))
100 max = std::numeric_limits<double>::min();
101 min = std::numeric_limits<double>::max();
105 for (
int n = 0; n < a_population.size(); ++n)
108 if (a_population[n].fitness > max)
110 max = a_population[n].fitness;
115 best =
new OrganismType(a_population[n]);
119 if (a_population[n].fitness < min)
121 min = a_population[n].fitness;
126 worst =
new OrganismType(a_population[n]);
130 mean += a_population[n].fitness;
133 mean /= double(a_population.size());
135 for (
int n = 0; n < a_population.size(); ++n)
137 double diff = a_population[n].fitness - mean;
138 variance += (diff * diff);
141 variance /=
static_cast<double>(a_population.size() - 1);
144 sigma = sqrt(variance);