r86601 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86600‎ | r86601 | r86602 >
Date:07:52, 21 April 2011
Author:rfaulk
Status:deferred
Tags:
Comment:
fixed some missing class references to self. Added updated confidence range reporting.
Modified paths:
  • /trunk/fundraiser-statistics/fundraiser-scripts/classes/HypothesisTest.py (modified) (history)

Diff [purge]

Index: trunk/fundraiser-statistics/fundraiser-scripts/classes/HypothesisTest.py
@@ -238,7 +238,7 @@
239239
240240 """
241241 def __init__(self):
242 - _data_loader_ = DL.TTestLoaderHelp()
 242+ self._data_loader_ = DL.TTestLoaderHelp()
243243
244244 """
245245 <description>
@@ -289,39 +289,23 @@
290290
291291
292292 """ lookup confidence """
293 -
294293 # get t and df
295294 degrees_of_freedom = math.ceil(degrees_of_freedom)
296295 if degrees_of_freedom > 30:
297296 degrees_of_freedom = 99
298297
 298+ p = self._data_loader_.get_pValue(degrees_of_freedom, t)
299299
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]
302304
303 - self._data_loader_.init_db()
 305+ if min_index > 0:
 306+ lower_p = probs[min_index - 1]
304307
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.'
321309
322 - p = _data_loader_.get_pValue(degrees_of_freedom, t)
323 -
324 - conf_str = str((1 - p) * 100) + '% confident about the winner.'
325 -
326310 return [means_1, means_2, std_devs_1, std_devs_2, conf_str]
327311
328312 """

Status & tagging log