Index: trunk/fundraiser-statistics/fundraiser-scripts/compute_confidence.py |
— | — | @@ -262,7 +262,9 @@ |
263 | 263 | self.gen_plot(means_1, means_2, std_devs_1, std_devs_2, times_indices, title, xlabel, ylabel, ranges, subplot_index, labels, fname) |
264 | 264 | |
265 | 265 | """ Print out results """ |
266 | | - self.print_metrics(test_name + '.txt', title, means_1, means_2, std_devs_1, std_devs_2, times_indices, labels) |
| 266 | + test_call = "run_test('" + test_name + "', '" + query_name + "', '" + metric_name + "', '" + campaign + "', '" + \ |
| 267 | + item_1 + "', '" + item_2 + "', '" + start_time + "', '" + end_time + "', " + str(interval) + ", " + str(num_samples) + ")" |
| 268 | + self.print_metrics(test_name + '.txt', title, means_1, means_2, std_devs_1, std_devs_2, times_indices, labels, test_call) |
267 | 269 | |
268 | 270 | return |
269 | 271 | |
— | — | @@ -326,15 +328,27 @@ |
327 | 329 | |
328 | 330 | |
329 | 331 | """ Print in Tabular form the means and standard deviation of each group over each interval """ |
330 | | - def print_metrics(self, filename, metric_name, means_1, means_2, std_devs_1, std_devs_2, times_indices, labels): |
| 332 | + def print_metrics(self, filename, metric_name, means_1, means_2, std_devs_1, std_devs_2, times_indices, labels, test_call): |
331 | 333 | |
332 | 334 | file = open(filename, 'w') |
333 | 335 | |
334 | | - # Compute % increase and report |
| 336 | + """ Compute % increase and report """ |
335 | 337 | av_means_1 = sum(means_1) / len(means_1) |
336 | 338 | av_means_2 = sum(means_2) / len(means_2) |
337 | 339 | percent_increase = math.fabs(av_means_1 - av_means_2) / min(av_means_1,av_means_2) * 100.0 |
338 | 340 | |
| 341 | + """ Compute the average standard deviations """ |
| 342 | + av_std_dev_1 = 0 |
| 343 | + av_std_dev_2 = 0 |
| 344 | + |
| 345 | + for i in range(len(std_devs_1)): |
| 346 | + av_std_dev_1 = av_std_dev_1 + math.pow(std_devs_1[i], 2) |
| 347 | + av_std_dev_2 = av_std_dev_2 + math.pow(std_devs_2[i], 2) |
| 348 | + |
| 349 | + av_std_dev_1 = math.pow(av_std_dev_1, 0.5) / len(std_devs_1) |
| 350 | + av_std_dev_2 = math.pow(av_std_dev_2, 0.5) / len(std_devs_1) |
| 351 | + |
| 352 | + """ Assign the winner """ |
339 | 353 | if av_means_1 > av_means_2: |
340 | 354 | winner = labels[0] |
341 | 355 | else: |
— | — | @@ -343,20 +357,38 @@ |
344 | 358 | win_str = "\nThe winner " + winner + " had a %.2f%s increase." |
345 | 359 | win_str = win_str % (percent_increase, '%') |
346 | 360 | |
| 361 | + print '\nCOMMAND = ' + test_call |
| 362 | + file.write('\nCOMMAND = ' + test_call) |
| 363 | + |
347 | 364 | print '\n\n' + metric_name |
348 | 365 | print win_str |
349 | 366 | print '\ninterval\tmean1\t\tmean2\t\tstddev1\t\tstddev2\n' |
350 | 367 | file.write('\n\n' + metric_name) |
| 368 | + file.write(win_str) |
351 | 369 | file.write('\n\ninterval\tmean1\t\tmean2\t\tstddev1\t\tstddev2\n\n') |
352 | | - file.write(win_str) |
353 | 370 | |
354 | | - # for i in range(1,len(times_indices) - 1): -- REMOVED with the |
| 371 | + |
| 372 | + """ Print out the parameters for each interval """ |
| 373 | + |
355 | 374 | for i in range(len(times_indices)): |
356 | 375 | line_args = str(i) + '\t\t' + '%.5f\t\t' + '%.5f\t\t' + '%.5f\t\t' + '%.5f\n' |
357 | 376 | line_str = line_args % (means_1[i], means_2[i], std_devs_1[i], std_devs_2[i]) |
358 | 377 | print line_str |
359 | 378 | file.write(line_str) |
| 379 | + |
| 380 | + """ Print out the averaged parameters """ |
| 381 | + line_args = '%.5f\t\t' + '%.5f\t\t' + '%.5f\t\t' + '%.5f\n' |
| 382 | + line_str = line_args % (av_means_1, av_means_2, av_std_dev_1, av_std_dev_2) |
| 383 | + |
| 384 | + print '\n\nOverall Parameters:\n' |
| 385 | + print '\nmean1\t\tmean2\t\tstddev1\t\tstddev2\n' |
| 386 | + print line_str |
| 387 | + |
| 388 | + file.write('\n\nOverall Parameters:\n') |
| 389 | + file.write('\nmean1\t\tmean2\t\tstddev1\t\tstddev2\n') |
| 390 | + file.write(line_str) |
360 | 391 | |
| 392 | + |
361 | 393 | file.close() |
362 | 394 | |
363 | 395 | |