Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding abanalyzer dependency. Adding method to utilize in admin UI to…

… determine statistical difference in categorial data according to abanalyzer
  • Loading branch information...
commit 312b78bd30e8581e47f658c0df2c2bb94f3ab7dd 1 parent 8ac8455
Andy Atkinson authored
View
17 lib/vanity/experiment/ab_test.rb
@@ -325,6 +325,23 @@ def score(probability = 90)
choice = outcome ? alts[outcome.id] : (best && best.probability >= probability ? best : nil)
Struct.new(:alts, :best, :base, :least, :choice).new(alts, best, base, least, choice)
end
+
+ def different?(score)
+ require 'abanalyzer'
+
+ values = score.alts.inject({}) do |values, alternative|
+ alternative_data = {:participations => alternative.participants, :conversions => alternative.converted}
+ values.merge!({alternative.name.to_sym => alternative_data})
+ values
+ end
+
+ begin
+ ABAnalyzer::ABTest.new(values).different?
+ rescue ABAnalyzer::InsufficientDataError
+ ::Rails.logger.error "vanity: caught ABAnalyzer::InsufficientDataError exception from ABAnalyzer"
+ false
+ end
+ end
# Use the result of #score to derive a conclusion. Returns an
# array of claims.
View
3  lib/vanity/templates/_ab_test.erb
@@ -1,7 +1,6 @@
<% score = experiment.score %>
<table>
- <caption>
- <%= experiment.conclusion(score).join(" ") %></caption>
+ <caption>Different? <%= experiment.different?(score) %></caption>
<% score.alts.each do |alt| %>
<tr class="<%= "choice" if score.choice == alt %>">
<td class="option"><%= alt.name.gsub(/^o/, "O") %>:</td>
View
1  vanity.gemspec
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 1.8.7'
spec.add_dependency "redis", "~>2.0"
spec.add_dependency "redis-namespace", "~>1.0.0"
+ spec.add_dependency "abanalyzer", "0.0.4"
end

0 comments on commit 312b78b

Please sign in to comment.
Something went wrong with that request. Please try again.