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);
double getMin()
Get the minimum fitness value for analyzed population.
Definition: stats.h:162
virtual ~fitness_stats()
Destructor.
Definition: stats.h:151
double getMean()
Get the mean (average) fitness value for analyzed population.
Definition: stats.h:168
A toolkit and framework for implementing evolutionary algorithms.
Definition: analyzer.h:60
double getSigma()
Get the standard deviation (sigma) value for fitness.
Definition: stats.h:174
OrganismType getBest()
Get the organism with the highest fitness for analyzed population.
Definition: stats.h:177
OrganismType getWorst()
Get the organism with the lowest fitness for analyzed population.
Definition: stats.h:180
double getVariance()
Get the fitness variance for analyzed population.
Definition: stats.h:171
double getMax()
Get the maximum fitness value for analyzed population.
Definition: stats.h:165
fitness_stats(const vector< OrganismType > &a_population)
Construct a statistics object for a specific population.
Definition: stats.h:95
Population fitness statistics.
Definition: stats.h:74