Index: trunk/fundraiser-statistics/fundraiser-scripts/classes/HypothesisTest.py |
— | — | @@ -238,7 +238,7 @@ |
239 | 239 |
|
240 | 240 | """
|
241 | 241 | def __init__(self):
|
242 | | - _data_loader_ = DL.TTestLoaderHelp()
|
| 242 | + self._data_loader_ = DL.TTestLoaderHelp()
|
243 | 243 |
|
244 | 244 | """
|
245 | 245 | <description>
|
— | — | @@ -289,39 +289,23 @@ |
290 | 290 |
|
291 | 291 |
|
292 | 292 | """ lookup confidence """
|
293 | | -
|
294 | 293 | # get t and df
|
295 | 294 | degrees_of_freedom = math.ceil(degrees_of_freedom)
|
296 | 295 | if degrees_of_freedom > 30:
|
297 | 296 | degrees_of_freedom = 99
|
298 | 297 |
|
| 298 | + p = self._data_loader_.get_pValue(degrees_of_freedom, t)
|
299 | 299 |
|
300 | | - """
|
301 | | - select_stmnt = 'select max(p) from t_test where degrees_of_freedom = ' + str(degrees_of_freedom) + ' and t >= ' + str(t)
|
| 300 | + """ Determine confidence range """
|
| 301 | + probs = [0.400000, 0.250000, 0.100000, 0.050000, 0.025000, 0.010000, 0.005000, 0.000500]
|
| 302 | + prob_diffs = [math.fabs(i-p) for i in probs]
|
| 303 | + min_index = min((n, i) for i, n in enumerate(prob_diffs))[1]
|
302 | 304 |
|
303 | | - self._data_loader_.init_db()
|
| 305 | + if min_index > 0:
|
| 306 | + lower_p = probs[min_index - 1]
|
304 | 307 |
|
305 | | - try:
|
306 | | - self._data_loader_._cur_.execute(select_stmnt)
|
307 | | - results = self._data_loader_._cur_.fetchone()
|
308 | | -
|
309 | | - if results[0] != None:
|
310 | | - p = float(results[0])
|
311 | | - else:
|
312 | | - p = .0005
|
313 | | - except:
|
314 | | - self._data_loader_._db_.rollback()
|
315 | | - self._data_loader_._db_.close()
|
316 | | - sys.exit('Could not execute: ' + select_stmnt)
|
317 | | -
|
318 | | - #print p
|
319 | | - self._data_loader_._db_.close()
|
320 | | - """
|
| 308 | + conf_str = 'Between ' + str((1 - lower_p) * 100) + '% and ' + str((1 - p) * 100) + '% confident about the winner.'
|
321 | 309 |
|
322 | | - p = _data_loader_.get_pValue(degrees_of_freedom, t)
|
323 | | -
|
324 | | - conf_str = str((1 - p) * 100) + '% confident about the winner.'
|
325 | | -
|
326 | 310 | return [means_1, means_2, std_devs_1, std_devs_2, conf_str]
|
327 | 311 |
|
328 | 312 | """
|