Commit 5b567ac7f0504a26b02a517f6a4fdb1f10e08c78
1 parent
bfb68e8d
Exists in
master
and in
1 other branch
modify irregular number of appearances test
add .5 to standard deviation so that we give some more breathing room when the standard deviation happens to be really low for a marketplace
Showing
1 changed file
with
4 additions
and
1 deletions
Show diff stats
lib/tasks/test_api.rake
... | ... | @@ -317,11 +317,14 @@ namespace :test_api do |
317 | 317 | if sum > 0: |
318 | 318 | stddev = Math.sqrt( appearances_by_choice_id.values.inject(0) { |sum, e| sum + (e - mean) ** 2 } / appearances_by_choice_id.size.to_f ) |
319 | 319 | |
320 | + # add small number to standard deviation to give some leniency when stddev is low | |
321 | + stddev += 0.5 | |
322 | + | |
320 | 323 | # this choice appears to have been deactivated then reactivated after |
321 | 324 | # a period of voting |
322 | 325 | ignore_choices = [133189] |
323 | 326 | appearances_by_choice_id.each do |choice_id, n_i| |
324 | - if (n_i > 10 && (n_i < (mean - 6*stddev)) || (n_i > mean + 6 *stddev)) && !ignore_choices.include?(choice_id) && Choice.find(choice_id).active? | |
327 | + if ((n_i < (mean - 6*stddev)) || (n_i > mean + 6 *stddev)) && !ignore_choices.include?(choice_id) && Choice.find(choice_id).active? | |
325 | 328 | error_message = "Choice #{choice_id} in Question ##{question.id} has an irregular number of appearances: #{n_i}, as compared to the mean: #{mean} and stddev #{stddev} for this question\n" |
326 | 329 | end |
327 | 330 | end | ... | ... |