From 9bc4c51a9122812d8a78fa2b87c2981b55e5c4b9 Mon Sep 17 00:00:00 2001 From: Stefan Wrobel Date: Thu, 1 Aug 2013 17:00:45 -0700 Subject: [PATCH] Whiplash: use all_completed_count instead of completed_count to take goal completions into account --- lib/split/algorithms/whiplash.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/split/algorithms/whiplash.rb b/lib/split/algorithms/whiplash.rb index f17742bd..199f743a 100644 --- a/lib/split/algorithms/whiplash.rb +++ b/lib/split/algorithms/whiplash.rb @@ -10,26 +10,26 @@ def self.choose_alternative(experiment) end private - + def self.arm_guess(participants, completions) a = [participants, 0].max b = [participants-completions, 0].max s = SimpleRandom.new; s.set_seed; s.beta(a+fairness_constant, b+fairness_constant) end - + def self.best_guess(alternatives) guesses = {} - alternatives.each do |alternative| - guesses[alternative.name] = arm_guess(alternative.participant_count, alternative.completed_count) + alternatives.each do |alternative| + guesses[alternative.name] = arm_guess(alternative.participant_count, alternative.all_completed_count) end gmax = guesses.values.max best = guesses.keys.select {|name| guesses[name] == gmax } return best.sample end - + def self.fairness_constant 7 end end end -end \ No newline at end of file +end