docs: def weighted_choice(seq, cdf):
      """
      Select a random element from a sequence, given cumulative probabilities of selection.
      
      See ``compute_fitness_cdf`` function for obtaining cumulative probabilities.
      
      seq:  sequence to select from
      cdf:  sequence with 1 cumulative probability value in [0, 1] for each element in ``seq``
      
      return:  randomly selected element
      """
      assert len(seq) == len(cdf)
      rand = random.random()
      
      for i, e in enumerate(seq):
          cp = cdf[i]
          assert 0 <= cp <= 1
          
          if rand < cp:
              return e