@staticmethod<EOL><INDENT>def p(i, sample_size, weights):<DEDENT>
<EOL>weight_i = weights[i]<EOL>weights_sum = sum(weights)<EOL>other_weights = list(weights)<EOL>del other_weights[i]<EOL>probability_of_i = <NUM_LIT:0><EOL>for picks in range(<NUM_LIT:0>, sample_size):<EOL><INDENT>permutations = list(itertools.permutations(other_weights, picks))<EOL>permutation_probabilities = []<EOL>for permutation in permutations:<EOL><INDENT>pick_probabilities = []<EOL>pick_weight_sum = weights_sum<EOL>for pick in permutation:<EOL><INDENT>pick_probabilities.append(pick / pick_weight_sum)<EOL>pick_weight_sum -= pick<EOL><DEDENT>pick_probabilities += [weight_i / pick_weight_sum]<EOL>permutation_probability = reduce(<EOL>lambda x, y: x * y, pick_probabilities<EOL>)<EOL>permutation_probabilities.append(permutation_probability)<EOL><DEDENT>probability_of_i += sum(permutation_probabilities)<EOL><DEDENT>return probability_of_i<EOL>
Given a weighted set and sample size return the probabilty that the
weight `i` will be present in the sample.

Created to test the output of the `SomeOf` maker class. The math was
provided by Andy Blackshaw - thank you dad :)