Index: trunk/fundraiser-statistics/fundraiser-scripts/compute_confidence.py |
— | — | @@ -236,13 +236,8 @@ |
237 | 237 | std_devs_2.insert(len(std_devs_2),0) |
238 | 238 | std_devs_1.insert(0,0) |
239 | 239 | std_devs_2.insert(0,0) |
| 240 | + |
240 | 241 | |
241 | | - #print means_1 |
242 | | - #print means_2 |
243 | | - #print std_devs_1 |
244 | | - #print std_devs_2 |
245 | | - #print times_indices |
246 | | - |
247 | 242 | # plot the results |
248 | 243 | xlabel = 'Hours' |
249 | 244 | subplot_index = 111 |
— | — | @@ -263,7 +258,7 @@ |
264 | 259 | self.gen_plot(means_1, means_2, std_devs_1, std_devs_2, times_indices, title, xlabel, ylabel, ranges, subplot_index, labels, fname) |
265 | 260 | |
266 | 261 | """ Print out results """ |
267 | | - self.print_metrics(test_name + '.txt', title, means_1, means_2, std_devs_1, std_devs_2, times_indices) |
| 262 | + self.print_metrics(test_name + '.txt', title, means_1, means_2, std_devs_1, std_devs_2, times_indices, labels) |
268 | 263 | |
269 | 264 | return |
270 | 265 | |
— | — | @@ -327,14 +322,29 @@ |
328 | 323 | |
329 | 324 | |
330 | 325 | """ Print in Tabular form the means and standard deviation of each group over each interval """ |
331 | | - def print_metrics(self, filename, metric_name, means_1, means_2, std_devs_1, std_devs_2, times_indices): |
| 326 | + def print_metrics(self, filename, metric_name, means_1, means_2, std_devs_1, std_devs_2, times_indices, labels): |
332 | 327 | |
333 | 328 | file = open(filename, 'w') |
334 | 329 | |
| 330 | + # Compute % increase and report |
| 331 | + av_means_1 = sum(means_1) / len(means_1) |
| 332 | + av_means_2 = sum(means_2) / len(means_2) |
| 333 | + percent_increase = math.fabs(av_means_1 - av_means_2) / min(av_means_1,av_means_2) * 100.0 |
| 334 | + |
| 335 | + if av_means_1 > av_means_2: |
| 336 | + winner = labels[0] |
| 337 | + else: |
| 338 | + winner = labels[1] |
| 339 | + |
| 340 | + win_str = "\nThe winner " + winner + " had a %s%.2f." |
| 341 | + win_str = win_str % ('%', percent_increase) |
| 342 | + |
335 | 343 | print '\n\n' + metric_name |
| 344 | + print win_str |
336 | 345 | print '\ninterval\tmean1\t\tmean2\t\tstddev1\t\tstddev2\n' |
337 | 346 | file.write('\n\n' + metric_name) |
338 | 347 | file.write('\n\ninterval\tmean1\t\tmean2\t\tstddev1\t\tstddev2\n\n') |
| 348 | + file.write(win_str) |
339 | 349 | |
340 | 350 | for i in range(1,len(times_indices) - 1): |
341 | 351 | line_args = str(i) + '\t\t' + '%.5f\t\t' + '%.5f\t\t' + '%.5f\t\t' + '%.5f\n' |