Commit f2e63f9d authored by Amelie Royer's avatar Amelie Royer

minor correction

parent f5955668
......@@ -48,7 +48,11 @@ void Stats::update(int cluster, double v) {
double Stats::get_mean(int cluster) {
if (cluster >= 0) {
return acc_mean[cluster] / lengths[cluster];
if (lengths[cluster] > 0) {
return acc_mean[cluster] / lengths[cluster];
} else {
return 0.;
}
} else {
double v, l = 0;
for (int i = 0; i < size; i++) {
......@@ -61,15 +65,18 @@ double Stats::get_mean(int cluster) {
double Stats::get_var(int cluster) {
if (cluster >= 0) {
double mean = get_mean(cluster);
return acc_var[cluster] / lengths[cluster] - mean * mean;
if (lengths[cluster] > 0) {
double mean = get_mean(cluster);
return acc_var[cluster] / lengths[cluster] - mean * mean;
} else {
return 0.;
}
} else {
double v, l = 0;
double v = 0;
for (int i = 0; i < size; i++) {
v += get_var(i);
l += 1;
}
return v / l;
return v / size;
}
}
......
......@@ -452,11 +452,12 @@ void evaluate_interactive(int n_sessions,
total_reward_s.update(cluster, total_reward / session_length);
// If Trap, do not count the rest
if (model.get_rep(state) != 1) {
success_s.update(cluster, 0);
continue;
}
// Normal execution, i.e. goal state
session_length_s.update(cluster, session_length);
success_s.update(cluster, ((model.get_rep(state) == 1) ? 1. : 0.)); // Goal in robot maze
success_s.update(cluster, 1); // Goal in robot maze
goal_reward_s.update(cluster, total_reward / session_length);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment