@staticmethod
def bin_search(array, prob):
    """Search for the lowest matching probability in array consisting of
        namedtuples. this is the sample component of roulette wheel sampling"""
    lo = 0
    hi = len(array) - 1
    while lo <= hi:
        mid = (lo + hi) // 2
        if array[mid].cumulative <= prob and (mid == len(array) - 1 or 
            array[mid + 1].cumulative > prob):
            return mid
        if array[mid].cumulative < prob:
            lo = mid + 1
        else:
            hi = mid
    return None
