def select_variant(experiment)
      # starts off at 0
      accum = 0.0
      sample = Kernel.rand

      # go through our experiments and return the variation that matches
      # our random value
      experiment.variations.each_with_index do |variation, i|

        # we want to record the index in the array for this variation
        variation.index = i
        variation.experiment_id = experiment.id

        # add the variation's weight to accum
        accum += variation.weight

        # return the variation if accum is more than our random value
        if sample <= accum
          return variation
        end
      end
      # default to nil
      return nil
    end
def select_variant(experiment)
      # starts off at 0
      accum = 0.0
      sample = Kernel.rand

      # go through our experiments and return the variation that matches
      # our random value
      experiment.variations.each_with_index do |variation, i|

        # we want to record the index in the array for this variation
        variation.index = i
        variation.experiment_id = experiment.id

        # add the variation's weight to accum
        accum += variation.weight

        # return the variation if accum is more than our random value
        if sample <= accum
          return variation
        end
      end
      # default to nil
      return nil
    end
Select a variant from a given experiment

 @param  experiment [Ostruct] The experiment to choose for

 @return [Ostruct, nil] The selected variant or nil if none is
 selected