environment/lib/python2.7/site-packages/IPython/parallel/controller/scheduler.py
def weighted(loads):
    """Pick two at random using inverse load as weight.

    Return the less loaded of the two.
    """
    # weight 0 a million times more than 1:
    weights = 1./(1e-6+numpy.array(loads))
    sums = weights.cumsum()
    t = sums[-1]
    x = random()*t
    y = random()*t
    idx = 0
    idy = 0
    while sums[idx] < x:
        idx += 1
    while sums[idy] < y:
        idy += 1
    if weights[idy] > weights[idx]:
        return idy
    else:
        return idx
def weighted(loads):
    # weight 0 a million times more than 1:
    weights = 1./(1e-6+numpy.array(loads))
    sums = weights.cumsum()
    t = sums[-1]
    x = random()*t
    y = random()*t
    idx = 0
    idy = 0
    while sums[idx] < x:
        idx += 1
    while sums[idy] < y:
        idy += 1
    if weights[idy] > weights[idx]:
        return idy
    else:
        return idx
def weighted ( loads ) : # weight 0 a million times more than 1: weights = 1. / ( 1e-6 + numpy . array ( loads ) ) sums = weights . cumsum ( ) t = sums [ - 1 ] x = random ( ) * t y = random ( ) * t idx = 0 idy = 0 while sums [ idx ] < x : idx += 1 while sums [ idy ] < y : idy += 1 if weights [ idy ] > weights [ idx ] : return idy else : return idx
Pick two at random using inverse load as weight.

    Return the less loaded of the two.
Pick two at random using inverse load as weight .