r84272 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84271‎ | r84272 | r84273 >
Date:22:02, 18 March 2011
Author:rfaulk
Status:deferred
Tags:
Comment:
Removed symbolic start ad end points from plotting. They were leading to some confusion in the presentation of results
Modified paths:
  • /trunk/fundraiser-statistics/fundraiser-scripts/compute_confidence.py (modified) (history)

Diff [purge]

Index: trunk/fundraiser-statistics/fundraiser-scripts/compute_confidence.py
@@ -202,18 +202,23 @@
203203 pylab.title(title)
204204 pylab.savefig(fname, format='png')
205205
 206+
 207+ """
 208+ ConfidenceTesting :: run_test
206209
 210+ Executes the confidence test - prints and plots the results
 211+ """
207212 def run_test(self, test_name, query_name, metric_name, campaign, item_1, item_2, start_time, end_time, interval, num_samples):
208213
209214 query_obj = qs.query_store()
210215
211 - # Retrieve values from database
 216+ """ Retrieve values from database """
212217 ret = self.query_tables(query_name, metric_name, campaign, item_1, item_2, start_time, end_time, interval, num_samples)
213218 metrics_1 = ret[0]
214219 metrics_2 = ret[1]
215220 times_indices = ret[2]
216221
217 - # run the confidence test
 222+ """ run the confidence test """
218223 ret = self.confidence_test(metrics_1, metrics_2, num_samples)
219224 means_1 = ret[0]
220225 means_2 = ret[1]
@@ -221,22 +226,22 @@
222227 std_devs_2 = ret[3]
223228 confidence = ret[4]
224229
225 - # Pad data with beginning and end points
226 - times_indices.insert(len(times_indices), math.ceil(times_indices[-1]))
227 - times_indices.insert(0, 0)
 230+ """ Pad data with beginning and end points """
 231+ # times_indices.insert(len(times_indices), math.ceil(times_indices[-1]))
 232+ # times_indices.insert(0, 0)
228233
229 - means_1.insert(len(means_1),means_1[-1])
230 - means_2.insert(len(means_2),means_2[-1])
231 - means_1.insert(0,means_1[0])
232 - means_2.insert(0,means_2[0])
 234+ # means_1.insert(len(means_1),means_1[-1])
 235+ # means_2.insert(len(means_2),means_2[-1])
 236+ # means_1.insert(0,means_1[0])
 237+ # means_2.insert(0,means_2[0])
233238
234 - std_devs_1.insert(len(std_devs_1),0)
235 - std_devs_2.insert(len(std_devs_2),0)
236 - std_devs_1.insert(0,0)
237 - std_devs_2.insert(0,0)
 239+ # std_devs_1.insert(len(std_devs_1),0)
 240+ # std_devs_2.insert(len(std_devs_2),0)
 241+ # std_devs_1.insert(0,0)
 242+ # std_devs_2.insert(0,0)
238243
239244
240 - # plot the results
 245+ """ plot the results """
241246 xlabel = 'Hours'
242247 subplot_index = 111
243248 fname = test_name + '.png'
@@ -344,7 +349,8 @@
345350 file.write('\n\ninterval\tmean1\t\tmean2\t\tstddev1\t\tstddev2\n\n')
346351 file.write(win_str)
347352
348 - for i in range(1,len(times_indices) - 1):
 353+ # for i in range(1,len(times_indices) - 1): -- REMOVED with the
 354+ for i in range(len(times_indices)):
349355 line_args = str(i) + '\t\t' + '%.5f\t\t' + '%.5f\t\t' + '%.5f\t\t' + '%.5f\n'
350356 line_str = line_args % (means_1[i], means_2[i], std_devs_1[i], std_devs_2[i])
351357 print line_str
@@ -456,7 +462,7 @@
457463
458464 def confidence_test(self, metrics_1, metrics_2, num_samples):
459465
460 - # retrieve means and variances
 466+ """ retrieve means and variances """
461467 ret = self.compute_parameters(metrics_1, metrics_2, num_samples)
462468 num_trials = ret[0]
463469 means_1 = ret[1]
@@ -475,9 +481,9 @@
476482 var_1_tot = 0
477483 var_2_tot = 0
478484
479 - # Compute the parameters for the Wald test
480 - # The difference of the means and the sum of the variances is used to compose the random variable W = X1 - X2 for each trial
481 - # where X{1,2} is the random variable corresponding to the group {1,2}
 485+ """ Compute the parameters for the student's t-test
 486+ The difference of the means and the sum of the variances is used to compose the random variable W = X1 - X2 for each trial
 487+ where X{1,2} is the random variable corresponding to the group {1,2} """
482488 for i in range(num_trials):
483489
484490 m_tot = m_tot + math.fabs(means_1[i] - means_2[i])
@@ -496,10 +502,6 @@
497503
498504 """ lookup confidence """
499505
500 - #print ''
501 - #print t
502 - #print degrees_of_freedom
503 -
504506 # get t and df
505507 degrees_of_freedom = math.ceil(degrees_of_freedom)
506508 if degrees_of_freedom > 30:

Status & tagging log