lib/split/algorithms/weighted_sample.rb in split-3.4.1 vs lib/split/algorithms/weighted_sample.rb in split-4.0.0.pre

- old
+ new

@@ -1,15 +1,16 @@ # frozen_string_literal: true + module Split module Algorithms module WeightedSample def self.choose_alternative(experiment) weights = experiment.alternatives.map(&:weight) total = weights.inject(:+) point = rand * total - experiment.alternatives.zip(weights).each do |n,w| + experiment.alternatives.zip(weights).each do |n, w| return n if w >= point point -= w end end end