def transmit_by_fitness(from_whom, to_whom=None, what=None):
    """Choose a parent with probability proportional to their fitness."""
    parents = from_whom
    parent_fs = [p.fitness for p in parents]
    parent_probs = [(f / (1.0 * sum(parent_fs))) for f in parent_fs]

    rnd = random.random()
    temp = 0.0
    for i, probability in enumerate(parent_probs):
        temp += probability
        if temp > rnd:
            parent = parents[i]
            break

    parent.transmit(what=what, to_whom=to_whom)
Choose a parent with probability proportional to their fitness.