You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: weighted_sample.rb
    path of file: ./repos/split/lib/split/algorithms
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module Split
  module Algorithms
    module WeightedSample
      def self.choose_alternative(experiment)
  
    
      def self.choose_alternative(experiment)
        weights = experiment.alternatives.map(&:weight)

        total = weights.inject(:+)
        point = rand * total

        experiment.alternatives.zip(weights).each do |n, w|
          return n if w >= point
          point -= w
        end
      end