Index: trunk/fundraiser-statistics/fundraiser-scripts/compute_confidence.py |
— | — | @@ -78,6 +78,8 @@ |
79 | 79 | formatted_sql_stmnt_1 = query_obj.format_query(query_name, sql_stmnt, [t1, t2, item_1, campaign]) |
80 | 80 | formatted_sql_stmnt_2 = query_obj.format_query(query_name, sql_stmnt, [t1, t2, item_2, campaign]) |
81 | 81 | |
| 82 | + # print formatted_sql_stmnt_1 |
| 83 | + |
82 | 84 | try: |
83 | 85 | err_msg = formatted_sql_stmnt_1 |
84 | 86 | |
— | — | @@ -92,9 +94,6 @@ |
93 | 95 | self.db.rollback() |
94 | 96 | sys.exit("Database Interface Exception:\n" + err_msg) |
95 | 97 | |
96 | | - #print results_1[metric_index] |
97 | | - #print results_2[metric_index] |
98 | | - |
99 | 98 | metrics_1.append(results_1[metric_index]) |
100 | 99 | metrics_2.append(results_2[metric_index]) |
101 | 100 | |
— | — | @@ -260,6 +259,7 @@ |
261 | 260 | |
262 | 261 | ylabel = metric_name |
263 | 262 | labels = [item_1, item_2] |
| 263 | + |
264 | 264 | self.gen_plot(means_1, means_2, std_devs_1, std_devs_2, times_indices, title, xlabel, ylabel, ranges, subplot_index, labels, fname) |
265 | 265 | |
266 | 266 | """ Print out results """ |
— | — | @@ -301,7 +301,7 @@ |
302 | 302 | var2 = 0 # variance of group 2 |
303 | 303 | |
304 | 304 | for j in range(num_samples): |
305 | | - index = i + j |
| 305 | + index = i * num_samples + j |
306 | 306 | |
307 | 307 | # Compute mean for each group |
308 | 308 | m1 = m1 + metrics_1[index] |
— | — | @@ -488,9 +488,9 @@ |
489 | 489 | |
490 | 490 | """ lookup confidence """ |
491 | 491 | |
492 | | - print '' |
493 | | - print t |
494 | | - print degrees_of_freedom |
| 492 | + #print '' |
| 493 | + #print t |
| 494 | + #print degrees_of_freedom |
495 | 495 | |
496 | 496 | # get t and df |
497 | 497 | degrees_of_freedom = math.ceil(degrees_of_freedom) |
— | — | @@ -504,14 +504,17 @@ |
505 | 505 | try: |
506 | 506 | self.cur.execute(select_stmnt) |
507 | 507 | results = self.cur.fetchone() |
508 | | - |
509 | | - p = float(results[0]) |
| 508 | + |
| 509 | + if results[0] != None: |
| 510 | + p = float(results[0]) |
| 511 | + else: |
| 512 | + p = .0005 |
510 | 513 | except: |
511 | 514 | self.db.rollback() |
512 | 515 | self.db.close() |
513 | 516 | sys.exit('Could not execute: ' + select_stmnt) |
514 | | - |
515 | | - print p |
| 517 | + |
| 518 | + #print p |
516 | 519 | self.db.close() |
517 | 520 | |
518 | 521 | conf_str = str((1 - p) * 100) + '% confident about the winner.' |