Permalink
Browse files

p-value

  • Loading branch information...
1 parent 9f4bcc6 commit 0920ed3ace4aef29ca335af09a30b0442367216f @vvgomes vvgomes committed Dec 26, 2012
Showing with 12 additions and 1 deletion.
  1. +12 −1 lib/whiplash.rb
View
13 lib/whiplash.rb
@@ -99,6 +99,8 @@ def spin!(test_name, goal, options=[true, false], mysession=nil, measure=false)
return options.first if options.count == 1
Whiplash.redis.sadd("whiplash/goals/#{goal}", test_name)
+
+ #p-value here somehow
if measure
choice = options.sample
else
@@ -135,9 +137,18 @@ def all_tests
end
def winning_option(test, options)
+ winning_options(test, options).first
+ end
+
+ def winning_options(test, options)
+ return options if options.size < 2
data_for_options(test, options).
each{ |k, v| v.map!(&:to_f) }.
- max_by{ |k, v| v[0] > 0 ? v[1]/v[0] : 0.0 }.first
+ max_by{ |k, v| v[0] > 0 ? v[1]/v[0] : 0.0 }[0, 2]
+ end
+
+ def p_value(test, options)
+ Significance.(winning_options(test, options).map{|k, v| [v[1], v[0]-v[1]]})
end
end

2 comments on commit 0920ed3

@woodhull

Why not use the livingsocial abanalyzer and statistics2 gems? I've been planning to add this stuff to whiplash as well. :-)

https://github.com/livingsocial/abanalyzer

@aaronsw
Please sign in to comment.