def transmit_by_fitness(from_whom, to_whom=None, what=None):
parents = from_whom<EOL>parent_fs = [p.fitness for p in parents]<EOL>parent_probs = [(f / (<NUM_LIT:1.0> * sum(parent_fs))) for f in parent_fs]<EOL>rnd = random.random()<EOL>temp = <NUM_LIT:0.0><EOL>for i, probability in enumerate(parent_probs):<EOL><INDENT>temp += probability<EOL>if temp > rnd:<EOL><INDENT>parent = parents[i]<EOL>break<EOL><DEDENT><DEDENT>parent.transmit(what=what, to_whom=to_whom)<EOL>
Choose a parent with probability proportional to their fitness.