code: def p(i, sample_size, weights):
          weight_i = weights[i]
          weights_sum = sum(weights)
          other_weights = list(weights)
          del other_weights[i]
          probability_of_i = 0
          for picks in range(0, sample_size):
              permutations = list(itertools.permutations(other_weights, picks))
              permutation_probabilities = []
              for permutation in permutations:
                  pick_probabilities = []
                  pick_weight_sum = weights_sum
                  for pick in permutation:
                      pick_probabilities.append(pick / pick_weight_sum)
                      pick_weight_sum -= pick
                  pick_probabilities += [weight_i / pick_weight_sum]
                  permutation_probability = reduce(
                      lambda x, y: x * y, pick_probabilities
                      )
                  permutation_probabilities.append(permutation_probability)
              probability_of_i += sum(permutation_probabilities)
          return probability_of_i